3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Products { public static function sortByPriceAscending($jsonString) { $info = json_decode($jsonString, true); print_r($info); usort($info, function($a, $b) { return $a['price'] - $b['price']; }); print_r($info); } } // For testing purposes (do not submit uncommented) echo Products::sortByPriceAscending('[{"name":"coffee","price":9.99},{"name":"eggs","price":1},{"name":"rice","price":4.04}]');

preferences:
23.96 ms | 406 KiB | 5 Q