3v4l.org

run code in 300+ PHP versions simultaneously
<?php $attributes = [ [ 'title' => 'Size', 'Variation' => ['Small', 'Medium', 'Large'] ], [ 'title' => 'Length', 'Variation' => ['Short', 'Regular', 'Long'] ], [ 'title' => 'Color', 'Variation' => ['Black', 'White'] ] ]; function combinate($result, $variations) { $ret = []; foreach( $variations as $v ) { foreach( $result as $r ) { $ret[] = $v . ' ' . $r; } } return $ret; } $ret = $attributes[count($attributes) - 1]['Variation']; for( $i = count($attributes) - 2; $i >= 0; $i--) { $ret = combinate($ret, $attributes[$i]['Variation']); } print_r($ret);
Output for 7.1.0 - 7.1.33, 7.2.0 - 7.2.34, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.33, 8.2.0 - 8.2.29, 8.3.0 - 8.3.28, 8.4.1 - 8.4.14, 8.5.0
Array ( [0] => Small Short Black [1] => Small Short White [2] => Small Regular Black [3] => Small Regular White [4] => Small Long Black [5] => Small Long White [6] => Medium Short Black [7] => Medium Short White [8] => Medium Regular Black [9] => Medium Regular White [10] => Medium Long Black [11] => Medium Long White [12] => Large Short Black [13] => Large Short White [14] => Large Regular Black [15] => Large Regular White [16] => Large Long Black [17] => Large Long White )
Output for 8.4.15
/bin/php-8.4.15: /usr/lib/libm.so.6: version `GLIBC_2.38' not found (required by /bin/php-8.4.15) /bin/php-8.4.15: /usr/lib/libm.so.6: version `GLIBC_2.35' not found (required by /bin/php-8.4.15) /bin/php-8.4.15: /usr/lib/libc.so.6: version `GLIBC_2.34' not found (required by /bin/php-8.4.15) /bin/php-8.4.15: /usr/lib/libc.so.6: version `GLIBC_2.38' not found (required by /bin/php-8.4.15)
Process exited with code 1.

preferences:
235.55 ms | 408 KiB | 5 Q