<?php
$array[] = array('id'=>1,'price'=>50);
$array[] = array('id'=>2,'price'=>70);
$array[] = array('id'=>3,'price'=>30);
$array[] = array('id'=>4,'price'=>20);
foreach ($array as $key=>$value){
$id[$key] = $value['id'];
$price[$key] = $value['price'];
}
array_multisort($price,SORT_NUMERIC,SORT_DESC,$id,SORT_STRING,SORT_ASC,$array);
echo '<pre>';
print_r($array);
echo '</pre>';
?>
if($sort == 'sort_desc'){
foreach ($hospitals as $key=>$value){
$sales_volume[$key] = $value['sales_volume'];
}
array_multisort($sales_volume,SORT_NUMERIC,SORT_DESC,$hospitals);
}elseif($sort =='sort_asc'){
foreach ($hospitals as $key=>$value){
$sales_volume[$key] = $value['sales_volume'];
}
array_multisort($sales_volume,SORT_NUMERIC,SORT_ASC,$hospitals);
}
网友评论