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->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
====== Chunk 0 ====== array ( 0 => 0, 1 => 1, 2 => 2, 3 => 3, 4 => 4, 5 => 5, 6 => 6, 7 => 7, 8 => 8, 9 => 9, 10 => 10, 11 => 11, 12 => 12, 13 => 13, 14 => 14, 15 => 15, 16 => 16, 17 => 17, 18 => 18, 19 => 19, 20 => 20, 21 => 21, 22 => 22, 23 => 23, 24 => 24, 25 => 25, 26 => 26, 27 => 27, 28 => 28, 29 => 29, 30 => 30, 31 => 31, 32 => 32, ) ====== Chunk 1 ====== array ( 0 => 33, 1 => 34, 2 => 35, 3 => 36, 4 => 37, 5 => 38, 6 => 39, 7 => 40, 8 => 41, 9 => 42, 10 => 43, 11 => 44, 12 => 45, 13 => 46, 14 => 47, 15 => 48, 16 => 49, 17 => 50, 18 => 51, 19 => 52, 20 => 53, 21 => 54, 22 => 55, 23 => 56, 24 => 57, 25 => 58, 26 => 59, 27 => 60, 28 => 61, 29 => 62, 30 => 63, 31 => 64, 32 => 65, ) ====== Chunk 2 ====== array ( 0 => 66, 1 => 67, 2 => 68, 3 => 69, 4 => 70, 5 => 71, 6 => 72, 7 => 73, 8 => 74, 9 => 75, 10 => 76, 11 => 77, 12 => 78, 13 => 79, 14 => 80, 15 => 81, 16 => 82, 17 => 83, 18 => 84, 19 => 85, 20 => 86, 21 => 87, 22 => 88, 23 => 89, 24 => 90, 25 => 91, 26 => 92, 27 => 93, 28 => 94, 29 => 95, 30 => 96, 31 => 97, 32 => 98, ) ====== Chunk 3 ====== array ( 0 => 99, 1 => 100, 2 => 101, 3 => 102, 4 => 103, 5 => 104, 6 => 105, 7 => 106, 8 => 107, 9 => 108, 10 => 109, 11 => 110, 12 => 111, 13 => 112, 14 => 113, 15 => 114, 16 => 115, 17 => 116, 18 => 117, 19 => 118, 20 => 119, 21 => 120, 22 => 121, 23 => 122, 24 => 123, 25 => 124, 26 => 125, )

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:
53.35 ms | 405 KiB | 8 Q