> function takes two dimensional array sorting:
The array format is as follows:
$goods = array(
0 => array(
“id”=>1,
“tag”=>array(
“price”=>”10”,
“old_price”=>”20”
)
),
1 => array(
“id”=>2,
“tag”=>array(
“price”=>”30”,
“old_price”=>”100”
)
),
2 => array(
“id”=>3,
“tag”=>array(
“price”=>”25”,
“old_price”=>”70”
)
),
3 => array(
“id”=>4,
“tag”=>array(
“price”=>”15”,
“old_price”=>”50”
)
)
);
$goods > is a collection of goods, each commodity with one.id,tag > is the specification of the commodity.price is the selling price of goods.old_price
$sort_arr = array();
foreach($goods as $key => &$val){
foreach($val[‘tag’ as $k => $v]{
$val[‘goods_arr’][] = array(“price”=>$v[“price”],”old_price”=>$v[“old_price”]);
})
foreach($val[‘goods_arr’] as $v){
$sort_arr[] = $v[‘price’];
}
array_multisort($sort_arr_sort,SORT_ASC,$val['goods_arr']);
$val['price_min'] = $val['goods_arr'][0]['price'];
$val['old_price_min'] = $val['goods_arr'][0][‘old_price’];
array_multisort($discount_sort,SORT_DESC,$val['goods_arr']);
$val['price_max'] = $val['goods_arr'][0]['price'];
$val['old_price_max'] = $val['goods_arr'][0]['old_price'];
}
This takes the lowest and highest prices for each item in the store’s collection, and gives the price range for each item when it is displayed in a store.
By as