3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php function array_split($input, $size=1) { $result = array(); for ($i = 0; $i < $size; $i++) { $remaining_slots = $size - $i; $remaining_items = count($input); $chunk_size = ceil($remaining_items / $remaining_slots); $chunk = array(); for ($e = 0; $e < $chunk_size; $e++) { $chunk[] = array_shift($input); } $result[] = $chunk; } return $result; } array_split(range(0, 10000), 4);
Output for 4.3.0 - 7.1.0