Home >Backend Development >PHP Tutorial >PHP two-dimensional array sorting
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!