3v4l.org

run code in 300+ PHP versions simultaneously
<?php function args_to_assoc_array($function, $args) { if (false === strpos($function, '::')) { $reflection = new ReflectionFunction($function); } else { $reflection = new ReflectionMethod(...explode('::', $function)); } $assoc = []; foreach ($reflection->getParameters() as $i => $parameter) { $assoc[$parameter->getName()] = $args[$i]; } return $assoc; } function f($x, $y) { return args_to_assoc_array(__METHOD__, func_get_args()); } class A { function m($z) { return args_to_assoc_array(__METHOD__, func_get_args()); } } var_dump(f(7, 2), (new A)->m(4));
Output for git.master, git.master_jit, rfc.property-hooks
array(2) { ["x"]=> int(7) ["y"]=> int(2) } array(1) { ["z"]=> int(4) }

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