3v4l.org

run code in 300+ PHP versions simultaneously
<?php // Everything you enter here will be executed by our servers. Try it! function iterator_compose() { foreach (array_reverse(func_get_args()) as $it) { if (is_callable($it)) { $prev = $it; } } } function iterator_chunk(\Traversable $it, $chunkSize) { $it = $it->rewind(); $chunk = []; $steps = range(0, $chunkSize); while (true) { foreach ($steps as $_) { if (!$it->valid()) { break 2; } $chunk[] = $it->current(); $it->next(); } yield $chunk; $chunk = []; } if ($chunk) { yield $chunk; } } $it = new ArrayIterator(range(0, 125)); foreach (iterator_chunk($it, 32) as $i => $c) { echo "====== Chunk $i ======\n"; var_export($c); echo "\n"; }
Output for git.master, git.master_jit, rfc.property-hooks
Fatal error: Uncaught Error: Call to a member function valid() on null in /in/KdI1n:21 Stack trace: #0 /in/KdI1n(40): iterator_chunk(NULL, 32) #1 {main} thrown in /in/KdI1n on line 21
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:
65.42 ms | 401 KiB | 8 Q