I have a form that contains three sets of checkboxes: Toppings, Sizes, Modifiers. When submitted, each returns an array of values. What I eventually need to do is create a separate record in a database for each possible combo of the three.
Example:
[15-Jul-2016 11:47:29] topps
[15-Jul-2016 11:47:29] Array
(
[0] => B
[1] => K
[2] => KT
[3] => ME
[4] => PK
)
[15-Jul-2016 11:47:29] mods
[15-Jul-2016 11:47:29] Array
(
[0] => R
)
[15-Jul-2016 11:47:29] sizes
[15-Jul-2016 11:47:29] Array
(
[0] => 7I
[1] => FM
[2] => L
[3] => LP
[4] => NL
)
I'll need to create a record for B R 7I, B R FM, B R L, etc. K R 7I, K R FM, and so on. What I'd like to have to begin with is an array that looks like this:
$records = array(
array('B', 'R', '7I'),
array('B', 'R', 'FM'),
// and so on
);
I'm not super-familiar with the array functions in PHP (array_walk
, array_map
, etc.)
Is there any way to generate my desired array without needing to do nested loops?