3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?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 5.3.0 - 7.1.0
array(2) { [0]=> array(2) { ["name"]=> string(6) "Potato" ["json"]=> string(30) "{"type":"Fruit","sortOrder":1}" } [1]=> array(2) { ["name"]=> string(5) "Apple" ["json"]=> string(30) "{"type":"Fruit","sortOrder":2}" } }
Output for 4.4.2 - 4.4.9, 5.1.0 - 5.2.17
Parse error: syntax error, unexpected T_FUNCTION, expecting ')' in /in/C36Ur on line 9
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.4.1, 5.0.0 - 5.0.5
Parse error: parse error, unexpected T_FUNCTION, expecting ')' in /in/C36Ur on line 9
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error, expecting `')'' in /in/C36Ur on line 9
Process exited with code 255.