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; } var_dump(array_split(range(0, 10000), 4));

Verbose script

This script was stopped because it was generating too much output