3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $data = [27, 38, 58, 82]; usort( $data, function ($a, $b) { echo "Comparing $a - $b", PHP_EOL; echo 'Element A should go ', (($a - $b < 0) ? 'before' : 'after'), ' element B', PHP_EOL; return $a - $b; } );
based on DVAqs
Output for 7.0.0 - 7.2.0
Comparing 27 - 38 Element A should go before element B Comparing 38 - 58 Element A should go before element B Comparing 58 - 82 Element A should go before element B
Output for 5.4.10 - 5.6.28
Comparing 38 - 27 Element A should go after element B Comparing 38 - 58 Element A should go before element B Comparing 82 - 38 Element A should go after element B Comparing 58 - 38 Element A should go after element B Comparing 82 - 58 Element A should go after element B
Output for 5.3.20 - 5.3.29
Parse error: syntax error, unexpected '[' in /in/8ljk5 on line 3
Process exited with code 255.