Home >Backend Development >PHP Tutorial >PHP two-dimensional array sorting

PHP two-dimensional array sorting

不言
不言Original
2018-04-28 10:41:501777browse

The content of this article is about how PHP can easily sort two-dimensional arrays. It has certain reference value. Now I share it with you. Friends in need can refer to it

array_multisort($volume,SORT_DESC,$data);$data[] = array('volume' => 67, 'edition' => 2);
$data[] = array('volume' => 86, 'edition' => 1);
$data[] = array('volume' => 85, 'edition' => 6);
$data[] = array('volume' => 98, 'edition' => 2);
$data[] = array('volume' => 86, 'edition' => 6);
$data[] = array('volume' => 67, 'edition' => 7);

foreach($data as $key=>$val){
    $volume[$key] = $val['volume'];
    $edition[$key] = $val['edition'];
}

array_multisort($volume,SORT_DESC,$data);

Related recommendations:

Example of PHP implementation of two-dimensional array quick sorting algorithm

Example of PHP implementation of two-dimensional array deduplication function

The above is the detailed content of PHP two-dimensional array sorting. 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