Home  >  Article  >  Backend Development  >  Detailed explanation of PHP multi-dimensional array merging and sorting functions

Detailed explanation of PHP multi-dimensional array merging and sorting functions

巴扎黑
巴扎黑Original
2017-09-14 10:22:431524browse

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:


'这个就是标题,第一个数组',
  '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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn