3v4l.org

run code in 300+ PHP versions simultaneously
<?php function l($name) { $a = ["a" => "aaa", "b" => ["a"=>"123456"], "a" => ["d"=>["e" =>"1%1"]]]; $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
Warning: Array to string conversion in /in/oMQhi on line 13 Array Warning: Array to string conversion in /in/oMQhi on line 24 array(1) { ["d"]=> string(5) "Array" } Warning: Array to string conversion in /in/oMQhi on line 13 Arraystring(6) "123456" Warning: Array to string conversion in /in/oMQhi on line 13 Array Warning: Undefined array key "c" in /in/oMQhi on line 19 Deprecated: str_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated in /in/oMQhi on line 24 string(0) "" Warning: Array to string conversion in /in/oMQhi on line 13 Arraystring(3) "145"

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:
44.31 ms | 402 KiB | 8 Q