Answers for "php how to sort an array of arrays by a value"

PHP
4

php sort by associative array value

//php 7+
usort($inventory, function ($item1, $item2) {
    return $item1['price'] <=> $item2['price'];
});
Posted by: Guest on February-02-2021

Code answers related to "php how to sort an array of arrays by a value"

Browse Popular Code Answers by Language