Problem:
There is such an array $arr:
[1]=> Array (3) {[0]=> string (")" .../r1822113797800000_aik1_20140626_190411.mp3 "[1]=> string (4)" AIK1 "[2]=> string (16)" 18221********* "}
[2]=> Array (3) {[0]=> string (")" .../r1822113797800000_aik1_20140626_190422.mp3 "[1]=> string (4)" AIK1 "[2]=> string (16)" 1822********* "}
......
......
Required to be sorted by time 20140626_190411
This uses PHP's multidimensional array sort Array_mutisort () function, as follows:
foreach($arr as $key=$row) { Preg_match("/[0-9]{4}_[0-9]{6}/",$row[0],$match)///Use regular expression to match time from ".../r1822113797800000_aik1_20140626_190422.mp3" 20140626_190422 $date _for_sort[$key] =$match[0];//time as a sort of keyword}Array_multisort($date _for_sort, SORT_ASC,$arr);//Use$date _for_sort in ascending order as a keyword for an array $arr
This function is quite useful ~
If the contents of the array are in Chinese, they need to be converted into GBK or GB2312 forms, which themselves use phonetic sorting and use the Iconv () function:
foreach ($arrbelong 2as$key=$row) { $belong 2_for_sort[$keyiconv(' UTF-8 ', ' GB2312 ',$row[' FullName ']); Array_multisort ($belong 2_for_sort, SORT_ASC,$arrbelong 2);