时间:2021-07-01 10:21:17 帮助过:23人阅读
- php $data = array(array("id" => 1, "name" => "Boney M", "rating" => 3),
- array("id" => 2, "name" => "Take That", "rating" => 1),
- array("id" => 3, "name" => "The Killers", "rating" => 4),
- array("id" => 4, "name" => "Lusain", "rating" => 3),
- ); foreach ($data as $key => $value) {
- $name[$key] = $value['name'];
- $rating[$key] = $value['rating'];
- }
- array_multisort($rating, $name, $data); print_r($data);?>
- Array ([0] => Array
- (
- [id] => 2
- [name] => Take That
- [rating] => 1
- ) [1] => Array
- (
- [id] => 1
- [name] => Boney M
- [rating] => 3
- )
- [2] => Array
- (
- [id] => 4
- [name] => Lusain
- [rating] => 3
- )
- [3] => Array
- (
- [id] => 3
- [name] => The Killers
- [rating] => 4
- )
- )
http://www.bkjia.com/PHPjc/446444.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/446444.htmlTechArticle我们在学习PHP时候,我们可能为PHP的多维数组排序的问题感到困惑,文章这里就详细的给大家介绍一下PHP多维数组排序的原理。PHP也允许在...