PHP simple multi-dimensional array merging and sorting function example, multi-dimensional sorting Function
This example describes how PHP can merge and sort multi-dimensional arrays. We will share this with you for your reference. The details are as follows:
<? Php $ record = array ('title' => 'This is the title, the first array', 'description' => 'descriptive content ', 'picurl' => 'photo link ', 'url' => 'link', 'juli' => 34 ); $ record_other = array ('title' => 'This is the title, the second array', 'description' => 'descriptive content ', 'picurl' => 'photo link', 'url' => 'link', 'juli' => 14); // merge the array $ re = array_merge ($ record, $ record_other); // sort in ascending order by the "juli" field $ juli_sort = array (); foreach ($ re as $ arr2) {$ juli_sort [] = $ arr2 ['juli'];} array_multisort ($ juli_so Rt, SORT_ASC, $ re); var_dump ($ re);?>
Running result:
Array (5) {["juli"] => int (14) ["url"] => string (4) "Link" ["description"] => string (8) "description" ["picurl"] => string (10) "photo link" ["title"] => string (24) "This is the title, the second array "}