3v4l.org

run code in 300+ PHP versions simultaneously
<?php /** * @author D.D.M. van Zelst * @copyright 2012 */ function scheduler($teams){ if (count($teams)%2 != 0){ array_push($teams,""); } $away = array_splice($teams,(count($teams)/2)); $home = $teams; for ($i=0; $i < count($home)+count($away)-1; $i++){ for ($j=0; $j<count($home); $j++){ $round[$i][$j]["Home"]=$home[$j]; $round[$i][$j]["Away"]=$away[$j]; } if(count($home)+count($away)-1 > 2){ array_unshift($away,array_shift(array_splice($home,1,1))); array_push($home,array_pop($away)); } } return $round; } ?> <?php $members = array("A","B","C","D","E"); ?> <?php $schedule = scheduler($members); ?> <?php foreach($schedule AS $round => $games){ echo "Round: ".($round+1)."\n"; foreach($games AS $play){ echo $play["Home"]." - ".$play["Away"]."\n"; } echo "\n"; } ?>
Output for 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
Notice: Only variables should be passed by reference in /in/WW28B on line 20 Notice: Only variables should be passed by reference in /in/WW28B on line 20 Notice: Only variables should be passed by reference in /in/WW28B on line 20 Notice: Only variables should be passed by reference in /in/WW28B on line 20 Notice: Only variables should be passed by reference in /in/WW28B on line 20 Round: 1 A - D B - E C - Round: 2 A - B C - D - E Round: 3 A - C - B E - D Round: 4 A - E - C D - B Round: 5 A - E D - B - C
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:
94.19 ms | 408 KiB | 5 Q