3v4l.org

run code in 300+ PHP versions simultaneously
<?php $json = '[ { "name": "A", "children": [ { "name": "B", "children": [ { "name": "C" }, { "name": "D", "children": [ { "name": "E" }, { "name": "F" } ] } ] }, { "name": "G" } ] }, { "name": "H" } ]'; $json = json_decode($json, true); function getArrayValuesRecursively(array $array){ $values = []; foreach ($array as $value) { if (is_array($value)) { $values = array_merge( $values, getArrayValuesRecursively($value) ); } else { $values[] = ['name' => $value]; } } return $values; } echo json_encode(getArrayValuesRecursively($json));
Output for git.master, git.master_jit, rfc.property-hooks
[{"name":"A"},{"name":"B"},{"name":"C"},{"name":"D"},{"name":"E"},{"name":"F"},{"name":"G"},{"name":"H"}]

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:
99.14 ms | 405 KiB | 5 Q