3v4l.org

run code in 300+ PHP versions simultaneously
<?php $arr = [ "one", "two", "three", "four", "five", "six", "seven", "eight", "nine", ]; function chunkRange(array $arr, int ... $sizes): Generator { $t = 0; $s = count($arr); do { foreach ($sizes as $n => $size) { yield array_slice($arr, $t, $size); $t += $size; } } while($t < $s); } foreach (chunkRange($arr, 1, 2) as $group) { var_dump($group); }
Output for git.master, git.master_jit, rfc.property-hooks
array(1) { [0]=> string(3) "one" } array(2) { [0]=> string(3) "two" [1]=> string(5) "three" } array(1) { [0]=> string(4) "four" } array(2) { [0]=> string(4) "five" [1]=> string(3) "six" } array(1) { [0]=> string(5) "seven" } array(2) { [0]=> string(5) "eight" [1]=> string(4) "nine" }

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