3v4l.org

run code in 300+ PHP versions simultaneously
<?php function stack(... $items) { foreach ($items as $item) { if ($next = yield $item) { yield from stack(... $next); } else { yield $next; } } } $items = [1,2,3]; $stack = stack(...$items); foreach ($stack as $item) { if ($item == 1) { $stack->send(['negate', -$item]); // push something onto the stack } if ($item == 2) { continue; // remove something from the stack } if ($item == 3) { $stack->send(['exponential', $item ** 2]); // push something onto the stack } if (isset($item)) { var_dump($item); } }
Output for git.master, git.master_jit, rfc.property-hooks
int(1) int(-1) int(3) int(9)

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