3v4l.org

run code in 300+ PHP versions simultaneously
<?php $input = [1, 2, 3, 5, 4, 7, 6, 8, 9]; $batches = generateBatches($input); function generateBatches($input) { $length = count($input); if (0 === $length) { return []; } $batches = []; $prev = $input[0]; $currentBatch = [$prev]; for ($i = 1; $i < $length; $i++) { if ($i < $prev) { $batches[] = $currentBatch; $currentBatch = []; } $currentBatch[] = $prev = $input[$i]; } $batches[] = $currentBatch; return $batches; } print_r($batches);
Output for git.master, git.master_jit, rfc.property-hooks
Array ( [0] => Array ( [0] => 1 [1] => 2 [2] => 3 [3] => 5 ) [1] => Array ( [0] => 4 [1] => 7 ) [2] => Array ( [0] => 6 [1] => 8 [2] => 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:
118.54 ms | 406 KiB | 5 Q