我有一个数组这些元素:通过包含数字对字符串数组进行排序?
/mypath/10_something_04_06.txt
/mypath/1_something_04_06.txt
/mypath/12_something_04_06.txt
/mypath/2_something_04_06.txt
/mypath/3_something_04_06.txt
现在我想对它进行排序,从而使/mypath/
后的数字被认为是。这是我试过的:
sort($myArray, SORT_NUMERIC);
sort($myArray, SORT_STRING);
它不起作用。 应该会有如下结果:
/mypath/1_something_04_06.txt
/mypath/2_something_04_06.txt
/mypath/3_something_04_06.txt
/mypath/10_something_04_06.txt
/mypath/12_something_04_06.txt
谢谢!
查一查'natsort'。 – georg
是的,那是一个,谢谢! – user1856596
[按字母顺序排列php数组]的可能重复(http://stackoverflow.com/questions/8295819/sorting-a-php-array-alphanumerically) – kero