3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $colors = array( array(0,0,0), array(255,0,0), array(0,255,0), array(0,0,255), array(255,255,0), array(0,255,255), array(255,0,255), array(192,192,192), array(255,255,255) ); function colorToLum($r, $g, $b) { return (0.299 * $r + 0.587 * $g + 0.114 * $g); } usort( $colors, function ($one, $two) { $lumOne = colorToLum($one[0], $one[1], $one[2]); $lumTwo = colorToLum($two[0], $two[1], $two[2]); return $lumTwo - $lumOne; } ); var_dump($colors);
Output for 5.3.0 - 5.6.28, 7.0.0 - 7.1.0
array(9) { [0]=> array(3) { [0]=> int(255) [1]=> int(255) [2]=> int(255) } [1]=> array(3) { [0]=> int(255) [1]=> int(255) [2]=> int(0) } [2]=> array(3) { [0]=> int(192) [1]=> int(192) [2]=> int(192) } [3]=> array(3) { [0]=> int(0) [1]=> int(255) [2]=> int(0) } [4]=> array(3) { [0]=> int(0) [1]=> int(255) [2]=> int(255) } [5]=> array(3) { [0]=> int(255) [1]=> int(0) [2]=> int(0) } [6]=> array(3) { [0]=> int(255) [1]=> int(0) [2]=> int(255) } [7]=> array(3) { [0]=> int(0) [1]=> int(0) [2]=> int(0) } [8]=> array(3) { [0]=> int(0) [1]=> int(0) [2]=> int(255) } }
Output for hhvm-3.10.0 - 3.12.0
array(9) { [0]=> array(3) { [0]=> int(255) [1]=> int(255) [2]=> int(0) } [1]=> array(3) { [0]=> int(255) [1]=> int(255) [2]=> int(255) } [2]=> array(3) { [0]=> int(192) [1]=> int(192) [2]=> int(192) } [3]=> array(3) { [0]=> int(0) [1]=> int(255) [2]=> int(0) } [4]=> array(3) { [0]=> int(0) [1]=> int(255) [2]=> int(255) } [5]=> array(3) { [0]=> int(255) [1]=> int(0) [2]=> int(0) } [6]=> array(3) { [0]=> int(255) [1]=> int(0) [2]=> int(255) } [7]=> array(3) { [0]=> int(0) [1]=> int(0) [2]=> int(0) } [8]=> array(3) { [0]=> int(0) [1]=> int(0) [2]=> int(255) } }
Output for 4.4.2 - 4.4.9, 5.1.0 - 5.2.17
Parse error: syntax error, unexpected T_FUNCTION in /in/d8m0m on line 21
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/d8m0m on line 21
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error in /in/d8m0m on line 21
Process exited with code 255.