This article mainly introduces the PHP two-dimensional array time sorting implementation code, the need for friends can refer to the following
Yesterday to sort the array of time to find, to sort by time, but PHP did not have this function, so found on the Internet this code, the first parameter is an array, the second is to sort the elements, the third is a sort of way,
Here is the code for PHP two-dimensional array ordering
function ArraySort ($arr, $keys, $type = ' asc ') { $keysvalue = $new _array = Array (); foreach ($arr as $k = + $v) { $keysvalue [$k] = $v [$keys]; } $type = = ' ASC '? Asort ($keysvalue): Arsort ($keysvalue); Reset ($keysvalue); foreach ($keysvalue as $k = + $v) { $new _array[$k] = $arr [$k]; } return $new _array; } $arr [] = Array ("name" = "1", "Time" =>1), $arr [] = Array ("name" = "2", "Time" =>2), ArraySort ($arr, "Time", " Desc ");
The above is the whole content of this article, I hope that everyone's study has helped.