3v4l.org

run code in 300+ PHP versions simultaneously
<?php $games = array(); $players = array_values($players); $tempplayers = $players; $n = count($players); $temp = $players; if (($n / 2) != round(($n / 2), 0)) { $rounds = $n; $games_per_go = ($n - 1) / 2; } else { $rounds = $n - 1; $games_per_go = $n / 2; } $offset = 0; $fixed = array_shift($tempplayers); $teams = $players; function scheduler($teams) { if (count($teams) % 2 != 0) { array_push($teams, "bye"); } $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++) { $games[$i][$j][Home] = $home[$j]; $games[$i][$j][Away] = $away[$j]; } if (count($home) + count($away) - 1 > 2) { array_unshift($away, array_shift(arra($home, 1, 1))); array_push($home, array_pop($away)); } } return $games; } var_dump(scheduler([1,2,3,4,5,6]));
Output for 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 - 8.5.1
Warning: Undefined variable $players in /in/LDsFO on line 4 Fatal error: Uncaught TypeError: array_values(): Argument #1 ($array) must be of type array, null given in /in/LDsFO:4 Stack trace: #0 /in/LDsFO(4): array_values(NULL) #1 {main} thrown in /in/LDsFO on line 4
Process exited with code 255.
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.
Output for 7.2.0 - 7.2.33, 7.3.0 - 7.3.31, 7.4.0 - 7.4.33
Notice: Undefined variable: players in /in/LDsFO on line 4 Warning: array_values() expects parameter 1 to be array, null given in /in/LDsFO on line 4 Warning: count(): Parameter must be an array or an object that implements Countable in /in/LDsFO on line 6 Warning: array_shift() expects parameter 1 to be array, null given in /in/LDsFO on line 17 Warning: Use of undefined constant Home - assumed 'Home' (this will throw an Error in a future version of PHP) in /in/LDsFO on line 29 Warning: Use of undefined constant Away - assumed 'Away' (this will throw an Error in a future version of PHP) in /in/LDsFO on line 30 Warning: Use of undefined constant Home - assumed 'Home' (this will throw an Error in a future version of PHP) in /in/LDsFO on line 29 Warning: Use of undefined constant Away - assumed 'Away' (this will throw an Error in a future version of PHP) in /in/LDsFO on line 30 Warning: Use of undefined constant Home - assumed 'Home' (this will throw an Error in a future version of PHP) in /in/LDsFO on line 29 Warning: Use of undefined constant Away - assumed 'Away' (this will throw an Error in a future version of PHP) in /in/LDsFO on line 30 Fatal error: Uncaught Error: Call to undefined function arra() in /in/LDsFO:33 Stack trace: #0 /in/LDsFO(41): scheduler(Array) #1 {main} thrown in /in/LDsFO on line 33
Process exited with code 255.
Output for 7.3.32 - 7.3.33
Warning: array_values() expects parameter 1 to be array, null given in /in/LDsFO on line 4 Warning: count(): Parameter must be an array or an object that implements Countable in /in/LDsFO on line 6 Warning: array_shift() expects parameter 1 to be array, null given in /in/LDsFO on line 17 Warning: Use of undefined constant Home - assumed 'Home' (this will throw an Error in a future version of PHP) in /in/LDsFO on line 29 Warning: Use of undefined constant Away - assumed 'Away' (this will throw an Error in a future version of PHP) in /in/LDsFO on line 30 Warning: Use of undefined constant Home - assumed 'Home' (this will throw an Error in a future version of PHP) in /in/LDsFO on line 29 Warning: Use of undefined constant Away - assumed 'Away' (this will throw an Error in a future version of PHP) in /in/LDsFO on line 30 Warning: Use of undefined constant Home - assumed 'Home' (this will throw an Error in a future version of PHP) in /in/LDsFO on line 29 Warning: Use of undefined constant Away - assumed 'Away' (this will throw an Error in a future version of PHP) in /in/LDsFO on line 30 Fatal error: Uncaught Error: Call to undefined function arra() in /in/LDsFO:33 Stack trace: #0 /in/LDsFO(41): scheduler(Array) #1 {main} thrown in /in/LDsFO on line 33
Process exited with code 255.
Output for 7.1.0 - 7.1.25
Notice: Undefined variable: players in /in/LDsFO on line 4 Warning: array_values() expects parameter 1 to be array, null given in /in/LDsFO on line 4 Warning: array_shift() expects parameter 1 to be array, null given in /in/LDsFO on line 17 Notice: Use of undefined constant Home - assumed 'Home' in /in/LDsFO on line 29 Notice: Use of undefined constant Away - assumed 'Away' in /in/LDsFO on line 30 Notice: Use of undefined constant Home - assumed 'Home' in /in/LDsFO on line 29 Notice: Use of undefined constant Away - assumed 'Away' in /in/LDsFO on line 30 Notice: Use of undefined constant Home - assumed 'Home' in /in/LDsFO on line 29 Notice: Use of undefined constant Away - assumed 'Away' in /in/LDsFO on line 30 Fatal error: Uncaught Error: Call to undefined function arra() in /in/LDsFO:33 Stack trace: #0 /in/LDsFO(41): scheduler(Array) #1 {main} thrown in /in/LDsFO on line 33
Process exited with code 255.

preferences:
189.86 ms | 415 KiB | 5 Q