3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $arr = [ 0 => 'DR-876-000-3.jpg', 1 => 'DRhgh000-2.jpg', 2 => 'DR-876-000-1.jpg', 3 => 'DR-876-000.png', 4 => 'DR-876-000.jpg', 5 => 'DR-876-000-4.jpg', ]; usort ( $arr , function ($a, $b) { return strnatcmp(pathinfo($a, PATHINFO_FILENAME), pathinfo($b, PATHINFO_FILENAME)); }); var_dump($arr);
based on 1OOue
Output for 7.0.0 - 7.2.0
array(6) { [0]=> string(14) "DR-876-000.png" [1]=> string(14) "DR-876-000.jpg" [2]=> string(16) "DR-876-000-1.jpg" [3]=> string(16) "DR-876-000-3.jpg" [4]=> string(16) "DR-876-000-4.jpg" [5]=> string(14) "DRhgh000-2.jpg" }
Output for 5.4.12 - 5.6.28
array(6) { [0]=> string(14) "DR-876-000.jpg" [1]=> string(14) "DR-876-000.png" [2]=> string(16) "DR-876-000-1.jpg" [3]=> string(16) "DR-876-000-3.jpg" [4]=> string(16) "DR-876-000-4.jpg" [5]=> string(14) "DRhgh000-2.jpg" }
Output for 5.3.22 - 5.3.29
Parse error: syntax error, unexpected '[' in /in/qhMXo on line 3
Process exited with code 255.