3v4l.org

run code in 300+ PHP versions simultaneously
<?php function breakPartitionsLongerThan ($partitions, $length) { $ret = array(); $partition = call_user_func_array ('array_merge', $partitions); $chunks = array_chunk ($partition, $length); if (count($chunks) > 1) for ($i = 0; $i < count ($chunks) - 1; $i++) // for every chunk except the last one, append the first address of the next chunk. $chunks[$i][] = $chunks[$i+1][0]; $ret = array_merge ($ret, $chunks); return $ret; } var_dump (breakPartitionsLongerThan([[1,2,3,4,5],[6,7,8,9]], 1));
Output for git.master, git.master_jit, rfc.property-hooks
array(9) { [0]=> array(2) { [0]=> int(1) [1]=> int(2) } [1]=> array(2) { [0]=> int(2) [1]=> int(3) } [2]=> array(2) { [0]=> int(3) [1]=> int(4) } [3]=> array(2) { [0]=> int(4) [1]=> int(5) } [4]=> array(2) { [0]=> int(5) [1]=> int(6) } [5]=> array(2) { [0]=> int(6) [1]=> int(7) } [6]=> array(2) { [0]=> int(7) [1]=> int(8) } [7]=> array(2) { [0]=> int(8) [1]=> int(9) } [8]=> array(1) { [0]=> int(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:
58.95 ms | 402 KiB | 8 Q