I am trying to figure out how to generate combinations of sizes with colors in php. Basically here is what I have:
The sizes and colors may vary depending on each product. The outcome I would like to have is like this:
Small Blue
Small Red
Small White
Medium Blue
Medium Red
Medium White
Large Blue
Large Red
Large White
$sizes = array('Small', 'Medium', 'Large');
$colors = array('Blue', 'Red', 'White');
foreach($sizes as $size) {
foreach($colors as $color) {
echo $size." ".$color;
}
}
That will give the output you described.