3v4l.org

run code in 300+ PHP versions simultaneously
<?php $a = ["a" => "aaa", "b.a" => "123456", "a.d.e" => "1%1"]; function l($name) { $keys = explode(".", $name); $key = array_shift($keys); $result = isset($a[$key]) ? $a[$key] : null; print $result; foreach($keys as $k) { if(!$result) return $name; $result = $result[$k]; } $args = func_get_args(); foreach($args as $k => $v) $result = str_replace("%{$k}", $v, $result); return $result; } var_dump(l("a")); var_dump(l("b.a")); var_dump(l("b.c")); var_dump(l("a.d.e", 45));
Output for git.master, git.master_jit, rfc.property-hooks
Deprecated: str_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated in /in/AaDid on line 23 string(0) "" string(3) "b.a" string(3) "b.c" string(5) "a.d.e"

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