二维数组排序方法

$new_ship = array(
    array('firstprice'=>6,'secondprice'=>4,),
    array('firstprice'=>7,'secondprice'=>4,),
    array('firstprice'=>5,'secondprice'=>7,),
    array('firstprice'=>7,'secondprice'=>5,),
);数组

 

//二维数组的排序
foreach ($new_ship as $key => $row)
{
    $volume[$key]  = $row['firstprice'];
    $edition[$key] = $row['secondprice'];
}
array_multisort($volume, SORT_DESC, $edition, SORT_DESC, $new_ship); 排序

 

此时$new_ship 就从新排序了。。ip

print_r($new_ship);it

相关文章
相关标签/搜索