This is continuation of my previous question.
I have this code :
$bag3 = 7;
$row = 4;
$arr = array("red", "green", "blue", "yellow");
foreach ($arr as $ay) {
for ($nom = 1; $nom <= $bag3; $nom++, $row++){
}
$m1 = ($row - $bag3) + 1;
echo "->mergeCells('A".$m1.":A".$row."')"."\n";
for ($nom = 1; $nom <= $bag3; $nom++, $row++){
$satu = ($row - $bag3) + 1;
echo "->setCellValue(A".$satu.",".$ay.")"."\n";
}
$dua = $satu + 1;
echo "->setCellValue(A".$dua.",".$ay.")"."\n";
}
And its output:
->mergeCells('A5:A11')
->setCellValue('A5',red)
->setCellValue('A6',red)
->setCellValue('A7',red)
->setCellValue('A8',red)
->setCellValue('A9',red)
->setCellValue('A10',red)
->setCellValue('A11',red)
->setCellValue('A12',red)
->mergeCells('A19:A25')
->setCellValue('A19',green)
->setCellValue('A20',green)
->setCellValue('A21',green)
->setCellValue('A22',green)
->setCellValue('A23',green)
->setCellValue('A24',green)
->setCellValue('A25',green)
->setCellValue('A26',green)
->mergeCells('A33:A39')
->setCellValue('A33',blue)
->setCellValue('A34',blue)
->setCellValue('A35',blue)
->setCellValue('A36',blue)
->setCellValue('A37',blue)
->setCellValue('A38',blue)
->setCellValue('A39',blue)
->setCellValue('A40',blue)
->mergeCells('A47:A53')
->setCellValue('A47',yellow)
->setCellValue('A48',yellow)
->setCellValue('A49',yellow)
->setCellValue('A50',yellow)
->setCellValue('A51',yellow)
->setCellValue('A52',yellow)
->setCellValue('A53',yellow)
->setCellValue('A54',yellow)
you see, from the second "Merge cell" $satu value become like ($dua + 7).
but what I wanted is the second $m1 = $dua + 1 and so the third and fourth, and value of $satu after "merge cell" start from ($dua + 1).
I have asked to my senior, but he seems as confused as me. So, what should I change in my code? Thanks and sorry for the bad English.
setCellValuefor eachmergeCells?A, what values do you want for theB? I can adjust my answer to suit.