create-matrix Helper for create matrix

  1. Install
  2. Usage examples

https://github.com/petrgrishin/create-matrix

Install

Add a dependency to your project's composer.json file if you use Composer to manage the dependencies of your project: ~~~ {

"require": {
    "petrgrishin/create-matrix": "~1.0"
}

} ~~~

Usage examples

<?php
use \PetrGrishin\CreateMatrix\CreateMatrix;

$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
        )

)
1 0
2 followers
0 downloads
Yii Version: all
License: MIT
Category: Validation
Tags: array, matrix
Developed by: Petr.Grishin
Created on: Mar 3, 2015
Last updated: 7 years ago

Related Extensions