3v4l.org

run code in 300+ PHP versions simultaneously
<?php function foo (iterable $ints) { $actualInts = []; foreach ($ints as $int) { $actualInts[] = (function (int $int): int { return $int; })($int); } return $actualInts; } function bar (iterable $ints) { $actualInts = (function (int ... $ints): array { return $ints; })(... array_values(is_array($ints) ? $ints : iterator_to_array($ints))); return $actualInts; } function getIt(): Generator { yield '1'; yield 3; } var_dump(foo(['1', 3])); var_dump(foo(getIt())); var_dump(bar(['1', 3])); var_dump(bar(getIt()));
Output for git.master, git.master_jit, rfc.property-hooks
array(2) { [0]=> int(1) [1]=> int(3) } array(2) { [0]=> int(1) [1]=> int(3) } array(2) { [0]=> int(1) [1]=> int(3) } array(2) { [0]=> int(1) [1]=> int(3) }

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