I have this array :
$values = Array
(
[0] => foo-1
[1] => foo-2
[2] => foo-3
[3] => foo-4
[4] => foo-5
[5] => foo-6
[6] => foo-7
[7] => foo-8
[8] => foo-9
[9] => foo-10
[10] => foo11
[...]
[30] => foo-31
[31] => foo-32
)
I need to explode the array all the 13 values, and get this :
echo "foo-1, foo-2, foo-3, foo-4, foo-5, foo-6 [...], foo-13";
echo "foo-14, foo-15, foo-16, foo-17 [...], foo-26";
echo "foo-27, foo-28, foo-29, foo-30, foo-31, foo-32";
So, this is my code :
$nVal = count($values);
$nbTab = $nVal / 13;
$nbTab = round($nbTab, 0, PHP_ROUND_HALF_UP);
for ($cpt = 0; $cpt <= $nbTab-1; $cpt++) {
$line = "";
if($cpt == 0)
$cptEntete = $cpt*12;
else
$cptEntete = ($cpt*12)+1;
echo "Cpt entete :".$cptEntete;
if($cpt+1 == $nbTab){
$jusque = $nVal;
}
else{
if($cpt == 0)
$jusque = 12;
else
$jusque = 12*($cpt+1);
}
for($cptEntete;$cptEntete <= $jusque;$cptEntete++){
$line.= $cptEntete." ,";
}
echo $line."<br />";
The problem is that I don't arrive to obtain good lines with my 13 values by line :(
Can help me please ?