3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array = array( array('name' => 'Apple', 'json' => '{"type":"Fruit","sortOrder":2}'), array('name' => 'Potato', 'json' => '{"type":"Fruit","sortOrder":1}') ); $array = array_map(function (array $values) { $json = json_decode($values['json'], true); return $values + array('sortOrder' => $json['SortOrder']); }, $array); usort($array, function (array $a, array $b) { return $a['sortOrder'] - $b['sortOrder']; }); $array = array_map(function (array $values) { unset($values['sortOrder']); return $values; }, $array); var_dump($array);
Output for git.master, git.master_jit, rfc.property-hooks
Warning: Undefined array key "SortOrder" in /in/1g38e on line 11 Warning: Undefined array key "SortOrder" in /in/1g38e on line 11 array(2) { [0]=> array(2) { ["name"]=> string(5) "Apple" ["json"]=> string(30) "{"type":"Fruit","sortOrder":2}" } [1]=> array(2) { ["name"]=> string(6) "Potato" ["json"]=> string(30) "{"type":"Fruit","sortOrder":1}" } }

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
33.73 ms | 402 KiB | 8 Q