Home > Article > Backend Development > Detailed explanation of PHP multi-dimensional array merging and sorting functions
This article mainly introduces the simple implementation of multi-dimensional array merging and sorting functions in PHP, involving PHP array merging, sorting and other related operations as well as the usage skills of array_merge, array_multisort and other functions. Friends in need can refer to this article
The example describes the simple implementation of multi-dimensional array merging and sorting functions in PHP. Share it with everyone for your reference, the details are as follows:
<?php $record=array( 'title' =>'这个就是标题,第一个数组', 'description' =>'描述内容', 'picurl' => '照片的链接', 'url' =>'链接', 'juli' => 34 ); $record_other=array( 'title' =>'这个就是标题,第二个数组', 'description' =>'描述内容', 'picurl' => '照片的链接', 'url' =>'链接', 'juli' => 14 ); //合并数组 $re=array_merge($record,$record_other); //升序排列,按照“juli”字段排列 $juli_sort = array(); foreach ($re as $arr2) { $juli_sort[] = $arr2['juli']; } array_multisort($juli_sort, SORT_ASC, $re); var_dump($re); ?>
Running results:
array(5) { ["juli"]=> int(14) ["url"]=> string(4) "链接" ["description"]=> string(8) "描述内容" ["picurl"]=> string(10) "照片的链接" ["title"]=> string(24) "这个就是标题,第二个数组" }
The above is the detailed content of Detailed explanation of PHP multi-dimensional array merging and sorting functions. For more information, please follow other related articles on the PHP Chinese website!