I have small difficulties to convert an array as I want, need some help from pros.
I have an array like that :
$inputs = array(
'size' => array(
's' => 's',
'm' => 'm',
'l' => 'l',
),
'color' => array(
'red' => 'red',
'blue' => 'blue',
),
'option' => 'option 1',
);
From this values, I need to create an array that combine all possibilities, like that :
$possibilities = array(
0 => array('size' => 's', 'color' => 'red', 'option' => 'option 1'),
1 => array('size' => 'm', 'color' => 'red', 'option' => 'option 1'),
2 => array('size' => 'l', 'color' => 'red', 'option' => 'option 1'),
3 => array('size' => 's', 'color' => 'blue', 'option' => 'option 1'),
4 => array('size' => 'm', 'color' => 'blue', 'option' => 'option 1'),
5 => array('size' => 'l', 'color' => 'blue', 'option' => 'option 1'),
);
I precise that I'm on laravel so I can use the collection methods, but even with this helpers methods, I can't find a way to obtain the $possibilities
array I want.
The original array is dynamic (can have more options with different label names), so I need something that is able to work no matter the size of the array neither the name of the labels.