3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Node { private $key, $kids; public function __construct(string $key, ?Node $parent = null) { if ($parent !== null) $parent->kids[$key] = $this; $this->key = $key; } public function match(array $parts): ?self { if (empty($parts)) return $this; $part = array_shift($parts); if (isset($this->kids[$part])) return $this->kids[$part]->match($parts); else return null; } public function getKey(): string { return $this->key; } } /* * root * |-- foo * `-- bar * `-- baz */ $root = new Node(""); $foo = new Node("foo", $root); $bar = new Node("bar", $root); $baz = new Node("baz", $bar); $node = $root->match(explode("/", "bar/baz")); if ($node !== null) echo $node->getKey();
Output for git.master, git.master_jit, rfc.property-hooks
baz

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:
67.17 ms | 401 KiB | 8 Q