3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $array = array( array( 'file' => 'file1', 'line' => 1, 'message' => 'foo' ), array( 'file' => 'file1', 'line' => 1, 'message' => 'bar' ) ); for ($i = 0; $i < 1; $i++){ usort($array, function($a, $b) { if ($a['file'] !== $b['file']) { return strcmp($a['file'], $b['file']); } else if ($a['line'] === $b['line']) { return 0; } else { return ($a['line'] < $b['line'] ? -1 : 1); } } ); } var_dump($array);
based on Sn2aY
Output for 7.0.0 - 7.2.0
array(2) { [0]=> array(3) { ["file"]=> string(5) "file1" ["line"]=> int(1) ["message"]=> string(3) "foo" } [1]=> array(3) { ["file"]=> string(5) "file1" ["line"]=> int(1) ["message"]=> string(3) "bar" } }
Output for 5.3.0 - 5.6.28
array(2) { [0]=> array(3) { ["file"]=> string(5) "file1" ["line"]=> int(1) ["message"]=> string(3) "bar" } [1]=> array(3) { ["file"]=> string(5) "file1" ["line"]=> int(1) ["message"]=> string(3) "foo" } }
Output for 4.4.2 - 4.4.9, 5.1.0 - 5.2.17
Parse error: syntax error, unexpected T_FUNCTION in /in/WDpY5 on line 16
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 T_FUNCTION in /in/WDpY5 on line 16
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error in /in/WDpY5 on line 16
Process exited with code 255.