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; }

preferences:
41.16 ms | 402 KiB | 5 Q