PHP笛卡尔积的一种实现方式

 $arr = [
            ['黑色', '红色', '白色', '黑色', '紫色'],
            ['36码', '37码', '38码', '39码', '40码'],
            ['男款', '女款'],
            ['运动', '休闲', '商务'],
        ];
        $count = count($arr);
        $result = $arr[0];
        $x = 0;
        while (true) {
            $x++;
            if ($x >= $count) break;
            $temp = [];
            foreach ($result as $item) {
                foreach ($arr[$x] as $item2) {
                    $temp[] = "$item-$item2";
                }
            }
            $result = $temp;
        }
        // 打印
        foreach ($result as $item) {
            echo "$item\n";
        }