3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $xmls = [6, 3, 2, 5, 4, 1]; echo memory_get_usage() . "\n\n"; usort($xmls, function($a, $b) { static $documents = array(); if (!isset($documents[$a])) { $documents[$a] = true; } if (!isset($documents[$b])) { $documents[$b] = true; } if ($a == $b) { $result = 0; } else { $result = $a < $b ? -1 : 1; } echo "a = {$a}, b = {$b}, result = {$result}\n" , memory_get_usage() , "\n" , print_r($documents, true) , "\n"; return $result; }); echo memory_get_usage() . "\n" . print_r($xmls, true) . "\n";
Output for 7.1.0
350040 a = 6, b = 3, result = 1 351568 Array ( [6] => 1 [3] => 1 ) a = 6, b = 2, result = 1 351568 Array ( [6] => 1 [3] => 1 [2] => 1 ) a = 3, b = 2, result = 1 351568 Array ( [6] => 1 [3] => 1 [2] => 1 ) a = 6, b = 5, result = 1 351568 Array ( [6] => 1 [3] => 1 [2] => 1 [5] => 1 ) a = 3, b = 5, result = -1 351568 Array ( [6] => 1 [3] => 1 [2] => 1 [5] => 1 ) a = 6, b = 4, result = 1 351568 Array ( [6] => 1 [3] => 1 [2] => 1 [5] => 1 [4] => 1 ) a = 5, b = 4, result = 1 351568 Array ( [6] => 1 [3] => 1 [2] => 1 [5] => 1 [4] => 1 ) a = 3, b = 4, result = -1 351568 Array ( [6] => 1 [3] => 1 [2] => 1 [5] => 1 [4] => 1 ) a = 6, b = 1, result = 1 351568 Array ( [6] => 1 [3] => 1 [2] => 1 [5] => 1 [4] => 1 [1] => 1 ) a = 5, b = 1, result = 1 351568 Array ( [6] => 1 [3] => 1 [2] => 1 [5] => 1 [4] => 1 [1] => 1 ) a = 4, b = 1, result = 1 351568 Array ( [6] => 1 [3] => 1 [2] => 1 [5] => 1 [4] => 1 [1] => 1 ) a = 3, b = 1, result = 1 351568 Array ( [6] => 1 [3] => 1 [2] => 1 [5] => 1 [4] => 1 [1] => 1 ) a = 2, b = 1, result = 1 351568 Array ( [6] => 1 [3] => 1 [2] => 1 [5] => 1 [4] => 1 [1] => 1 ) 350472 Array ( [0] => 1 [1] => 2 [2] => 3 [3] => 4 [4] => 5 [5] => 6 )
Output for 7.0.6 - 7.0.14
350400 a = 6, b = 3, result = 1 351928 Array ( [6] => 1 [3] => 1 ) a = 6, b = 2, result = 1 352056 Array ( [6] => 1 [3] => 1 [2] => 1 ) a = 3, b = 2, result = 1 352056 Array ( [6] => 1 [3] => 1 [2] => 1 ) a = 6, b = 5, result = 1 352056 Array ( [6] => 1 [3] => 1 [2] => 1 [5] => 1 ) a = 3, b = 5, result = -1 352056 Array ( [6] => 1 [3] => 1 [2] => 1 [5] => 1 ) a = 6, b = 4, result = 1 352056 Array ( [6] => 1 [3] => 1 [2] => 1 [5] => 1 [4] => 1 ) a = 5, b = 4, result = 1 352056 Array ( [6] => 1 [3] => 1 [2] => 1 [5] => 1 [4] => 1 ) a = 3, b = 4, result = -1 352056 Array ( [6] => 1 [3] => 1 [2] => 1 [5] => 1 [4] => 1 ) a = 6, b = 1, result = 1 352056 Array ( [6] => 1 [3] => 1 [2] => 1 [5] => 1 [4] => 1 [1] => 1 ) a = 5, b = 1, result = 1 352056 Array ( [6] => 1 [3] => 1 [2] => 1 [5] => 1 [4] => 1 [1] => 1 ) a = 4, b = 1, result = 1 352056 Array ( [6] => 1 [3] => 1 [2] => 1 [5] => 1 [4] => 1 [1] => 1 ) a = 3, b = 1, result = 1 352056 Array ( [6] => 1 [3] => 1 [2] => 1 [5] => 1 [4] => 1 [1] => 1 ) a = 2, b = 1, result = 1 352056 Array ( [6] => 1 [3] => 1 [2] => 1 [5] => 1 [4] => 1 [1] => 1 ) 350584 Array ( [0] => 1 [1] => 2 [2] => 3 [3] => 4 [4] => 5 [5] => 6 )
Output for 7.0.0 - 7.0.5
350400 a = 6, b = 3, result = 1 351552 Array ( [6] => 1 [3] => 1 ) a = 6, b = 2, result = 1 351680 Array ( [6] => 1 [3] => 1 [2] => 1 ) a = 3, b = 2, result = 1 351680 Array ( [6] => 1 [3] => 1 [2] => 1 ) a = 6, b = 5, result = 1 351680 Array ( [6] => 1 [3] => 1 [2] => 1 [5] => 1 ) a = 3, b = 5, result = -1 351680 Array ( [6] => 1 [3] => 1 [2] => 1 [5] => 1 ) a = 6, b = 4, result = 1 351680 Array ( [6] => 1 [3] => 1 [2] => 1 [5] => 1 [4] => 1 ) a = 5, b = 4, result = 1 351680 Array ( [6] => 1 [3] => 1 [2] => 1 [5] => 1 [4] => 1 ) a = 3, b = 4, result = -1 351680 Array ( [6] => 1 [3] => 1 [2] => 1 [5] => 1 [4] => 1 ) a = 6, b = 1, result = 1 351680 Array ( [6] => 1 [3] => 1 [2] => 1 [5] => 1 [4] => 1 [1] => 1 ) a = 5, b = 1, result = 1 351680 Array ( [6] => 1 [3] => 1 [2] => 1 [5] => 1 [4] => 1 [1] => 1 ) a = 4, b = 1, result = 1 351680 Array ( [6] => 1 [3] => 1 [2] => 1 [5] => 1 [4] => 1 [1] => 1 ) a = 3, b = 1, result = 1 351680 Array ( [6] => 1 [3] => 1 [2] => 1 [5] => 1 [4] => 1 [1] => 1 ) a = 2, b = 1, result = 1 351680 Array ( [6] => 1 [3] => 1 [2] => 1 [5] => 1 [4] => 1 [1] => 1 ) 350584 Array ( [0] => 1 [1] => 2 [2] => 3 [3] => 4 [4] => 5 [5] => 6 )
Output for hhvm-3.10.0 - 3.12.0
2097152 a = 6, b = 3, result = 1 2097152 Array ( [6] => 1 [3] => 1 ) a = 6, b = 2, result = 1 2097152 Array ( [6] => 1 [3] => 1 [2] => 1 ) a = 3, b = 2, result = 1 2097152 Array ( [6] => 1 [3] => 1 [2] => 1 ) a = 6, b = 5, result = 1 2097152 Array ( [6] => 1 [3] => 1 [2] => 1 [5] => 1 ) a = 3, b = 5, result = -1 2097152 Array ( [6] => 1 [3] => 1 [2] => 1 [5] => 1 ) a = 6, b = 4, result = 1 2097152 Array ( [6] => 1 [3] => 1 [2] => 1 [5] => 1 [4] => 1 ) a = 5, b = 4, result = 1 2097152 Array ( [6] => 1 [3] => 1 [2] => 1 [5] => 1 [4] => 1 ) a = 3, b = 4, result = -1 2097152 Array ( [6] => 1 [3] => 1 [2] => 1 [5] => 1 [4] => 1 ) a = 6, b = 1, result = 1 2097152 Array ( [6] => 1 [3] => 1 [2] => 1 [5] => 1 [4] => 1 [1] => 1 ) a = 5, b = 1, result = 1 2097152 Array ( [6] => 1 [3] => 1 [2] => 1 [5] => 1 [4] => 1 [1] => 1 ) a = 4, b = 1, result = 1 2097152 Array ( [6] => 1 [3] => 1 [2] => 1 [5] => 1 [4] => 1 [1] => 1 ) a = 3, b = 1, result = 1 2097152 Array ( [6] => 1 [3] => 1 [2] => 1 [5] => 1 [4] => 1 [1] => 1 ) a = 2, b = 1, result = 1 2097152 Array ( [6] => 1 [3] => 1 [2] => 1 [5] => 1 [4] => 1 [1] => 1 ) 2097152 Array ( [0] => 1 [1] => 2 [2] => 3 [3] => 4 [4] => 5 [5] => 6 )
Output for 5.6.0 - 5.6.28
223232 a = 2, b = 3, result = -1 224600 Array ( [2] => 1 [3] => 1 ) a = 1, b = 2, result = -1 225264 Array ( [2] => 1 [3] => 1 [1] => 1 ) a = 2, b = 6, result = -1 225400 Array ( [2] => 1 [3] => 1 [1] => 1 [6] => 1 ) a = 4, b = 2, result = 1 225536 Array ( [2] => 1 [3] => 1 [1] => 1 [6] => 1 [4] => 1 ) a = 5, b = 2, result = 1 225672 Array ( [2] => 1 [3] => 1 [1] => 1 [6] => 1 [4] => 1 [5] => 1 ) a = 6, b = 2, result = 1 225672 Array ( [2] => 1 [3] => 1 [1] => 1 [6] => 1 [4] => 1 [5] => 1 ) a = 5, b = 6, result = -1 225672 Array ( [2] => 1 [3] => 1 [1] => 1 [6] => 1 [4] => 1 [5] => 1 ) a = 3, b = 5, result = -1 225672 Array ( [2] => 1 [3] => 1 [1] => 1 [6] => 1 [4] => 1 [5] => 1 ) a = 4, b = 5, result = -1 225672 Array ( [2] => 1 [3] => 1 [1] => 1 [6] => 1 [4] => 1 [5] => 1 ) a = 3, b = 4, result = -1 225672 Array ( [2] => 1 [3] => 1 [1] => 1 [6] => 1 [4] => 1 [5] => 1 ) 223808 Array ( [0] => 1 [1] => 2 [2] => 3 [3] => 4 [4] => 5 [5] => 6 )
Output for 5.5.0 - 5.5.38
223232 a = 2, b = 3, result = -1 224584 Array ( [2] => 1 [3] => 1 ) a = 1, b = 2, result = -1 225248 Array ( [2] => 1 [3] => 1 [1] => 1 ) a = 2, b = 6, result = -1 225384 Array ( [2] => 1 [3] => 1 [1] => 1 [6] => 1 ) a = 4, b = 2, result = 1 225520 Array ( [2] => 1 [3] => 1 [1] => 1 [6] => 1 [4] => 1 ) a = 5, b = 2, result = 1 225656 Array ( [2] => 1 [3] => 1 [1] => 1 [6] => 1 [4] => 1 [5] => 1 ) a = 6, b = 2, result = 1 225656 Array ( [2] => 1 [3] => 1 [1] => 1 [6] => 1 [4] => 1 [5] => 1 ) a = 5, b = 6, result = -1 225656 Array ( [2] => 1 [3] => 1 [1] => 1 [6] => 1 [4] => 1 [5] => 1 ) a = 3, b = 5, result = -1 225656 Array ( [2] => 1 [3] => 1 [1] => 1 [6] => 1 [4] => 1 [5] => 1 ) a = 4, b = 5, result = -1 225656 Array ( [2] => 1 [3] => 1 [1] => 1 [6] => 1 [4] => 1 [5] => 1 ) a = 3, b = 4, result = -1 225656 Array ( [2] => 1 [3] => 1 [1] => 1 [6] => 1 [4] => 1 [5] => 1 ) 223792 Array ( [0] => 1 [1] => 2 [2] => 3 [3] => 4 [4] => 5 [5] => 6 )
Output for 5.4.10 - 5.4.45
223728 a = 2, b = 3, result = -1 225080 Array ( [2] => 1 [3] => 1 ) a = 1, b = 2, result = -1 225744 Array ( [2] => 1 [3] => 1 [1] => 1 ) a = 2, b = 6, result = -1 225880 Array ( [2] => 1 [3] => 1 [1] => 1 [6] => 1 ) a = 4, b = 2, result = 1 226016 Array ( [2] => 1 [3] => 1 [1] => 1 [6] => 1 [4] => 1 ) a = 5, b = 2, result = 1 226152 Array ( [2] => 1 [3] => 1 [1] => 1 [6] => 1 [4] => 1 [5] => 1 ) a = 6, b = 2, result = 1 226152 Array ( [2] => 1 [3] => 1 [1] => 1 [6] => 1 [4] => 1 [5] => 1 ) a = 5, b = 6, result = -1 226152 Array ( [2] => 1 [3] => 1 [1] => 1 [6] => 1 [4] => 1 [5] => 1 ) a = 3, b = 5, result = -1 226152 Array ( [2] => 1 [3] => 1 [1] => 1 [6] => 1 [4] => 1 [5] => 1 ) a = 4, b = 5, result = -1 226152 Array ( [2] => 1 [3] => 1 [1] => 1 [6] => 1 [4] => 1 [5] => 1 ) a = 3, b = 4, result = -1 226152 Array ( [2] => 1 [3] => 1 [1] => 1 [6] => 1 [4] => 1 [5] => 1 ) 224288 Array ( [0] => 1 [1] => 2 [2] => 3 [3] => 4 [4] => 5 [5] => 6 )
Output for 5.4.0 - 5.4.9
223752 a = 2, b = 3, result = -1 225104 Array ( [2] => 1 [3] => 1 ) a = 1, b = 2, result = -1 225768 Array ( [2] => 1 [3] => 1 [1] => 1 ) a = 2, b = 6, result = -1 225904 Array ( [2] => 1 [3] => 1 [1] => 1 [6] => 1 ) a = 4, b = 2, result = 1 226040 Array ( [2] => 1 [3] => 1 [1] => 1 [6] => 1 [4] => 1 ) a = 5, b = 2, result = 1 226176 Array ( [2] => 1 [3] => 1 [1] => 1 [6] => 1 [4] => 1 [5] => 1 ) a = 6, b = 2, result = 1 226176 Array ( [2] => 1 [3] => 1 [1] => 1 [6] => 1 [4] => 1 [5] => 1 ) a = 5, b = 6, result = -1 226176 Array ( [2] => 1 [3] => 1 [1] => 1 [6] => 1 [4] => 1 [5] => 1 ) a = 3, b = 5, result = -1 226176 Array ( [2] => 1 [3] => 1 [1] => 1 [6] => 1 [4] => 1 [5] => 1 ) a = 4, b = 5, result = -1 226176 Array ( [2] => 1 [3] => 1 [1] => 1 [6] => 1 [4] => 1 [5] => 1 ) a = 3, b = 4, result = -1 226176 Array ( [2] => 1 [3] => 1 [1] => 1 [6] => 1 [4] => 1 [5] => 1 ) 224312 Array ( [0] => 1 [1] => 2 [2] => 3 [3] => 4 [4] => 5 [5] => 6 )
Output for 4.4.2 - 4.4.9, 5.1.0 - 5.3.29
Parse error: syntax error, unexpected '[' in /in/Um0ac on line 3
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.4.1, 5.0.0 - 5.0.5
Parse error: parse error, unexpected '[' in /in/Um0ac on line 3
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error in /in/Um0ac on line 3
Process exited with code 255.