3v4l.org

run code in 300+ PHP versions simultaneously
<?php function breakPartitionsLongerThan ($partitions, $length) { $ret = array(); foreach ($partitions as $partition) { $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,10], 2));
Output for git.master, git.master_jit, rfc.property-hooks
Fatal error: Uncaught TypeError: array_chunk(): Argument #1 ($array) must be of type array, int given in /in/CSqpo:6 Stack trace: #0 /in/CSqpo(6): array_chunk(1, 2) #1 /in/CSqpo(16): breakPartitionsLongerThan(Array, 2) #2 {main} thrown in /in/CSqpo on line 6
Process exited with code 255.

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:
38.76 ms | 401 KiB | 8 Q