3v4l.org

run code in 300+ PHP versions simultaneously
<?php $lg = ['league_1', 'league_2', 'league_3']; $hm = ['home 1','home 2','home 3','home 4','home 5','home 6',]; $aw = ['away 1','away 2','away 3','away 4','away 5','away 6',]; $sup = [3,1,2]; $u = 0; foreach ($sup as $ind=>$num){ for($i=0;$i<$num;$i++){ $item['group']['name'] = $lg[$ind]; $item['group']['user_1'] = $hm[$u+$i]; $item['group']['user_2'] = $aw[$u+$i]; $groups[] = $item; } $u+=$i++; } print_r($groups);
Output for 7.1.26 - 7.1.33, 7.2.17 - 7.2.33, 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] => Array ( [group] => Array ( [name] => league_1 [user_1] => home 1 [user_2] => away 1 ) ) [1] => Array ( [group] => Array ( [name] => league_1 [user_1] => home 2 [user_2] => away 2 ) ) [2] => Array ( [group] => Array ( [name] => league_1 [user_1] => home 3 [user_2] => away 3 ) ) [3] => Array ( [group] => Array ( [name] => league_2 [user_1] => home 4 [user_2] => away 4 ) ) [4] => Array ( [group] => Array ( [name] => league_3 [user_1] => home 5 [user_2] => away 5 ) ) [5] => Array ( [group] => Array ( [name] => league_3 [user_1] => home 6 [user_2] => away 6 ) ) )
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:
173.97 ms | 409 KiB | 5 Q