Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/petrgrishin/create-matrix
Helper for create matrix
https://github.com/petrgrishin/create-matrix
Last synced: 8 days ago
JSON representation
Helper for create matrix
- Host: GitHub
- URL: https://github.com/petrgrishin/create-matrix
- Owner: petrgrishin
- Created: 2015-03-03T20:43:41.000Z (almost 10 years ago)
- Default Branch: master
- Last Pushed: 2015-03-03T22:16:14.000Z (almost 10 years ago)
- Last Synced: 2024-11-08T16:17:03.985Z (2 months ago)
- Language: PHP
- Size: 145 KB
- Stars: 3
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# create-matrix
[![Travis CI](https://img.shields.io/travis/petrgrishin/create-matrix/master.svg?style=flat-square)](https://travis-ci.org/petrgrishin/create-matrix)Helper for create matrix
## Installation
Add a dependency to your project's composer.json file if you use [Composer](http://getcomposer.org/) to manage the dependencies of your project:
```json
{
"require": {
"petrgrishin/create-matrix": "~1.0"
}
}
```## Usage examples
#### Create matrix by the variants
```php
$variants = [
'a' => [1, 2],
'b' => [10, 20],
];
$matrix = CreateMatrix::byVariants($variants)->getArray();// result
$matrix = Array
(
[0] => Array
(
[a] => 1
[b] => 10
)[1] => Array
(
[a] => 1
[b] => 20
)[2] => Array
(
[a] => 2
[b] => 10
)[3] => Array
(
[a] => 2
[b] => 20
))
```#### Create matrix with variant an empty value
```php
$variants = [
'a' => [1, null],
'b' => [10, null],
];
$matrix = CreateMatrix::byVariants($variants)->getArray();// result
$matrix = Array
(
[0] => Array
(
[a] => 1
[b] => 10
)[1] => Array
(
[a] => 1
[b] =>
)[2] => Array
(
[a] =>
[b] => 10
)[3] => Array
(
[a] =>
[b] =>
))
```