3v4l.org

run code in 500+ PHP versions simultaneously
<?php $result = json_decode('[ { "id": "GRP-25", "text": "All Areas", "groupid": 0, "leaf": false, "qtip": "Common", "link": null, "helplink": null, "children": [ { "id": "GRP-25", "text": "All Areas", "groupid": 0, "leaf": true, "qtip": "Common", "link": null, "helplink": null } ] }, { "id": "GRP-25", "text": "All Areas", "groupid": 0, "leaf": false, "qtip": "Common", "link": null, "helplink": null } ]', true); function changeLeafId(array &$data) { foreach ($data as $k => $v) { // recursive call if (is_array($v)) { changeLeafId($data[$k]); continue; } // update 'id' from 'leaf' if ($k == 'id' && $data['leaf'] ?? false) { $data[$k] = 'GRP-' . $v; } } } changeLeafId($result); print_r($result);
Output for git.master, git.master_jit, rfc.property-hooks
Array ( [0] => Array ( [id] => GRP-25 [text] => All Areas [groupid] => 0 [leaf] => [qtip] => Common [link] => [helplink] => [children] => Array ( [0] => Array ( [id] => GRP-GRP-25 [text] => All Areas [groupid] => 0 [leaf] => 1 [qtip] => Common [link] => [helplink] => ) ) ) [1] => Array ( [id] => GRP-25 [text] => All Areas [groupid] => 0 [leaf] => [qtip] => Common [link] => [helplink] => ) )

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:
64.31 ms | 1426 KiB | 4 Q