3v4l.org

run code in 300+ PHP versions simultaneously
<?php function filter($array, callable $c) { $result = []; foreach ($array as $key => $value) { if ($c($value, $key)) { $result[$key] = $value; } } return $result; } var_dump(filter(['foo', '', 'bar'], function ($value) { return strlen($value); })); // Internal functions already throw on superfluous args var_dump(filter(['foo', '', 'bar'], 'strlen'));
Output for git.master, git.master_jit, rfc.property-hooks
array(2) { [0]=> string(3) "foo" [2]=> string(3) "bar" } Fatal error: Uncaught ArgumentCountError: strlen() expects exactly 1 argument, 2 given in /in/0QdoS:6 Stack trace: #0 /in/0QdoS(6): strlen('foo', 0) #1 /in/0QdoS(18): filter(Array, 'strlen') #2 {main} thrown in /in/0QdoS on line 6
Process exited with code 255.

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:
51.87 ms | 406 KiB | 5 Q