Answer the question
In order to leave comments, you need to log in
How to sort an array - stdclass by key value?
Hello. There is an array $variants
print_r array:
Array
(
[0] => stdClass Object
(
[id] => 84
[product_id] => 48
[price] => 277.00
[compare_price] => 300.00
[name] => Яблочный
)
[1] => stdClass Object
(
[id] => 58
[product_id] => 43
[price] => 277.00
[compare_price] => 1233.00
[name] => Черный
)
[2] => stdClass Object
(
[id] => 85
[product_id] => 48
[price] => 277.00
[compare_price] => 413.00
[name] => Малахитовый
)
)
function cmp_function($a, $b){
return ($a['name'] > $b['name']);
}
uasort($variants, 'cmp_function');
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question