3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?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}]');
based on UJHK3
Output for 5.6.0 - 7.3.1
Array ( [0] => Array ( [name] => coffee [price] => 9.99 ) [1] => Array ( [name] => eggs [price] => 1 ) [2] => Array ( [name] => rice [price] => 4.04 ) ) Array ( [0] => Array ( [name] => eggs [price] => 1 ) [1] => Array ( [name] => rice [price] => 4.04 ) [2] => Array ( [name] => coffee [price] => 9.99 ) )