生成大小和颜色的PHP组合

I am trying to figure out how to generate combinations of sizes with colors in php. Basically here is what I have:

  • Sizes: Small, Medium, Large
  • Size Count: 3
  • Colors: Blue, Red, White
  • Color Count: 3

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.