3v4l.org

run code in 300+ PHP versions simultaneously
<?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"; } } }
Output for 5.5.0 - 5.5.35, 5.6.0 - 5.6.28, 7.0.0 - 7.0.20, 7.1.0 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.4, 8.3.6
11 - 10 9 - 8 7 - 6
Output for 8.3.5
Warning: PHP Startup: Unable to load dynamic library 'sodium.so' (tried: /usr/lib/php/8.3.5/modules/sodium.so (libsodium.so.23: cannot open shared object file: No such file or directory), /usr/lib/php/8.3.5/modules/sodium.so.so (/usr/lib/php/8.3.5/modules/sodium.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0 11 - 10 9 - 8 7 - 6

preferences:
220.29 ms | 402 KiB | 258 Q