3v4l.org

run code in 300+ PHP versions simultaneously
<?php function paths(array $a) { // if first item is an array, recurse if (is_array(reset($a))) { foreach ($a as $k => $v) { foreach (paths($v) as $path) { // yield "key - subpath" yield sprintf('%s - %s', $k, $path); } } } else { // yield leaf yield sprintf('(%s)', implode(', ', $a)); } } $obj = json_decode('{ "Group1": { "Blue": { "Round": [ "Harold", "Arthur", "Tom" ] }, "Green": { "Round": [ "Harold" ], "Circle": [ "Todd", "Mike" ] } }, "Group2": { "Blue": { "Round": [ "Peter" ] } } }', true); foreach (paths($obj) as $path) { printf("%s\n", $path); }
Output for git.master, git.master_jit, rfc.property-hooks
Group1 - Blue - Round - (Harold, Arthur, Tom) Group1 - Green - Round - (Harold) Group1 - Green - Circle - (Todd, Mike) Group2 - Blue - Round - (Peter)

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