A simple way to share a two-dimensional array ordering
PHP Code
function Array_sort ($arr, $field, $by =sort_asc) { foreach ($arr as $v) { $r [] = $v [$field]; } Array_multisort ($r, $by, $arr); return $arr; } $array = Array ( ´name´=>´ mobile ´,´brand´=>´ nokia ´,´price´=>3000), array (´name´=>´ laptop ´,´ brand´=>´lenovo´,´price´=>4000), ); $a =array_sort ($array, ´price´,sort_desc); echo ""; Print_r ($a);
Welcome to use ...
------Solution--------------------
It's always been this ah, hehe.
------Solution--------------------
It's better not to encapsulate it. Direct Array_multisort
------Solution--------------------
There are automatic sorting functions in PHP.
------Solution--------------------
Do you want to encapsulate one of the three-dimensional arrays?
------Solution--------------------
discuss
Do you want to encapsulate one of the three-dimensional arrays?