- array_map: documentation ( source)
- var_dump: documentation ( source)
- array_splice: documentation ( source)
- implode: documentation ( source)
- ceil: documentation ( source)
- range: documentation ( source)
<?php
function restructureArray3($array, $x)
{
while ($array)
$return [] = array_splice($array, 0, ceil(sizeof($array) / $x--));
return $return;
}
$array = range(1, 7);
$x = 3;
var_dump(array_map(function($array)
{ return implode(', ', $array); }, restructureArray3($array, $x)));