开发者

Generate PHP combinations for size and color

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜