Math icon indicating copy to clipboard operation
Math copied to clipboard

There should be a way to preserve keys with CartesianProduct

Open ostrolucky opened this issue 7 years ago • 0 comments

This is a feature request.

Input:

$data = [
    'hair' => [
        'blond',
        'black'
    ],
    'eyes' => [
        'blue',
        'green',
    ]
];

Expected output:

Array
(
    [0] => Array
        (
            [hair] => blond
            [eyes] => blue
        )

    [1] => Array
        (
            [hair] => blond
            [eyes] => green
        )

    [2] => Array
        (
            [hair] => black
            [eyes] => blue
        )

    [3] => Array
        (
            [hair] => black
            [eyes] => green
        )
)

Use case:

combining all possible route parameter values for sitemap generation


Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

ostrolucky avatar Mar 21 '19 19:03 ostrolucky