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) { $batches = []; $batchNumber = 0; $prev = 0; foreach ($input as $i) { $batches[$batchNumber][] = $i; if ($i > 1 && $i - $prev < 1) { $batchNumber++; } $prev = $i; } 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 [4] => 4 ) [1] => Array ( [0] => 7 [1] => 6 ) [2] => Array ( [0] => 8 [1] => 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:
53.93 ms | 406 KiB | 5 Q