3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $json = '{ "example": "1", "example2": 2, "text": "3", "info": { "agent": 4, "sum": 5, "collection": [{ "Name": "6", "Pic": "7" }, { "Name": "8", "Pic": "9" }, { "Name": "10", "Pic": "11" }] } }'; $result = json_decode ($json, true); foreach($result as $key => $value){ if($key == 'info'){ $keys = array_keys($value['collection']); array_multisort( array_column($value['collection'], 'Pic'), SORT_DESC, SORT_NUMERIC, $value['collection'], $keys ); $value = array_combine($keys, $value['collection']); foreach($value as $val){ echo $val['Pic']." - ".$val['Name']."\n"; } } }
based on UsmgI
Output for 5.5.0 - 7.3.1
11 - 10 9 - 8 7 - 6