3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array = [ '2022-06-30', '2022-04-20', '2021-04-07', '2022-09-09', '2022-03-08', '2022-06-02', '2021-08-07', '2022-10-12' ]; $today = '2022-06-02'; // date('Y-m-d'); usort($array, fn($a, $b) => ($a > $today && $b > $today ? -1 : 1) * ($a <=> $b)); var_export($array);
Output for 7.4.0 - 7.4.33, 8.0.1 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.7
array ( 0 => '2021-04-07', 1 => '2021-08-07', 2 => '2022-03-08', 3 => '2022-04-20', 4 => '2022-06-02', 5 => '2022-10-12', 6 => '2022-09-09', 7 => '2022-06-30', )

preferences:
110.78 ms | 403 KiB | 122 Q