This article mainly introduces the php Method for sorting arrays by specified keys. It involves the php Method for sorting arrays and has some reference value. For more information, see
This article mainly introduces the php Method for sorting arrays by specified keys. It involves the php Method for sorting arrays and has some reference value. For more information, see
This example describes how to sort arrays by specified keys in php. Share it with you for your reference. The specific implementation method is as follows:
Function array_sort ($ arr, $ keys, $ orderby = 'asc ') {$ keysvalue = $ new_array = array (); foreach ($ arr as $ k => $ v) {$ keysvalue [$ k] = $ v [$ keys];} if ($ orderby = 'asc ') {asort ($ keysvalue );} else {arsort ($ keysvalue);} reset ($ keysvalue); foreach ($ keysvalue as $ k => $ v) {$ new_array [] = $ arr [$ k];} return $ new_array ;}
I hope this article will help you with php programming.
,