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

PHP two-dimensional array sorting

不言
Release: 2023-03-25 06:22:02
Original
1781 people have browsed it

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);
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template