how to sorting multiple array object in php
sorting multiple array object using php
function sort_arr_of_obj($array, $sortby, $direction='asc') {
$sortedArr = array();
$tmp_Array = array();
foreach($array as $k => $v) {
$tmp_Array[] = strtolower($v->$sortby);
}
if($direction=='asc'){
asort($tmp_Array);
}else{
arsort($tmp_Array);
}
foreach($tmp_Array as $k=>$tmp){
$sortedArr[] = $array[$k];
}
return $sortedArr;
}
$lowestsellerpricesort= sort_arr_of_obj($response->categories->category->items->product->offers->offer,'basePrice','asc');
Comments
Post a Comment