3v4l.org

run code in 300+ PHP versions simultaneously
<?php function joinNumbers($a, $b) { $t=10; while($b>=$t) $t*=10; return $a*$t+$b; } function arrangeNumbers() { $a = [1,34,3,98,9,76,45,4]; $size=count($a)/count($a[0]); for($i=0;$i<$size-1;$i++) for($j=$i+1;$j<$size;$j++) if(joinNumbers($a[$i],$a[$j])<joinNumbers($a[$j],$a[$i])) swap($a[$i],$a[$j]); printf("Number is : "); for($i=0;$i<$size;$i++) printf("%d",$a[$i]); printf("\n\n"); } arrangeNumbers();
Output for 8.0.10 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.6
Fatal error: Uncaught TypeError: count(): Argument #1 ($value) must be of type Countable|array, int given in /in/GuuYD:15 Stack trace: #0 /in/GuuYD(29): arrangeNumbers() #1 {main} thrown in /in/GuuYD on line 15
Process exited with code 255.
Output for 8.0.0 - 8.0.9
Fatal error: Uncaught TypeError: count(): Argument #1 ($var) must be of type Countable|array, int given in /in/GuuYD:15 Stack trace: #0 /in/GuuYD(29): arrangeNumbers() #1 {main} thrown in /in/GuuYD on line 15
Process exited with code 255.
Output for 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33
Warning: count(): Parameter must be an array or an object that implements Countable in /in/GuuYD on line 15 Fatal error: Uncaught Error: Call to undefined function swap() in /in/GuuYD:20 Stack trace: #0 /in/GuuYD(29): arrangeNumbers() #1 {main} thrown in /in/GuuYD on line 20
Process exited with code 255.
Output for 7.0.0 - 7.0.20, 7.1.0 - 7.1.25
Fatal error: Uncaught Error: Call to undefined function swap() in /in/GuuYD:20 Stack trace: #0 /in/GuuYD(29): arrangeNumbers() #1 {main} thrown in /in/GuuYD on line 20
Process exited with code 255.
Output for 5.5.24 - 5.5.35, 5.6.8 - 5.6.28
Fatal error: Call to undefined function swap() in /in/GuuYD on line 20
Process exited with code 255.

preferences:
163.79 ms | 402 KiB | 198 Q