3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array = [ 'Adolf', 'Doe', 'adept', 'Done', 'dear', 'adopt', 'Deer' ]; $startsWith = 'do'; usort( $array, fn($a, $b) => (stripos($a, $startsWith) !== 0) <=> (stripos($b, $startsWith) !== 0) ?: strcasecmp($a, $b) ); var_export($array);
Output for 7.4.0 - 7.4.33, 8.0.1 - 8.0.30, 8.1.0 - 8.1.34, 8.2.0 - 8.2.30, 8.3.0 - 8.3.30, 8.4.1 - 8.4.18, 8.5.0 - 8.5.3
array ( 0 => 'Doe', 1 => 'Done', 2 => 'adept', 3 => 'Adolf', 4 => 'adopt', 5 => 'dear', 6 => 'Deer', )

preferences:
142.02 ms | 479 KiB | 5 Q