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