3v4l.org

run code in 500+ PHP versions simultaneously
<?php $array = range(0, 10); usort($array, withBool(...)); print(implode(', ', $array)).PHP_EOL; // 9, 10, 7, 8, 5, 6, 4, 3, 2, 1, 0 usort($array, withInt(...)); print(implode(', ', $array)).PHP_EOL; // 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 function withBool($a, $b) : bool { return $a <=> $b; } function withInt($a, $b) : int { return $a <=> $b; } ?>
Output for 8.1.34, 8.2.0 - 8.2.30, 8.3.0 - 8.3.30, 8.4.1 - 8.4.21, 8.5.0 - 8.5.6
Deprecated: usort(): Returning bool from comparison function is deprecated, return an integer less than, equal to, or greater than zero in /in/BATHJ on line 5 9, 10, 7, 8, 5, 6, 4, 3, 2, 1, 0 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10

preferences:
21.53 ms | 865 KiB | 4 Q