php - fpdf select 案例 $行

php - fpdf select case $row

我正在使用 FPDF 并具有以下代码:

// Data
foreach($data as $row)
{ 
$this->SetFont('Arial','',12);
$this->Cell($w[0],6,$row[0],'','','C'); //Year
$this->Cell($w[1],6,$row[1],'','','R'); //Details
$this->Cell($w[14],6,number_format($row[14],0,",","."),'',0,'R'); //Totals
$this->Ln();
}

我想要 select 个案例并且有类似的东西:

for i=1 to 7
  select case $row
    case 1
    case 2
    ..
  end select
loop

我希望每行数据都具有不同的样式,并且由于我知道这些行每 7 行重复一次,所以我可以有一个循环并使 selection.

这应该为您提供继续前进的详细信息。从您提供的内容中不清楚您将对 7 种行样式中的每一种进行哪种类型的样式设置,因此我只是对每种可能性进行了评论。

$stylecount = 1;
// Data
foreach($data as $row) {
   switch ($stylecount) {

       case 1:
           // set style 1 here
       break;

       case 2:
           // set style 2 here
       break;

       case 3:
           // set style 3 here
       break;

       case 4:
           // set style 4 here
       break;

       case 5:
           // set style 5 here
       break;

       case 6:
           // set style 6 here
       break;

       case 7:
           // set style 7 here
           $stylecount = 0;  // reset count
       break;
   }  // end of switch

   $this->SetFont('Arial','',12);
   $this->Cell($w[0],6,$row[0],'','','C'); //Year
   $this->Cell($w[1],6,$row[1],'','','R'); //Details
   $this->Cell($w[14],6,number_format($row[14],0,",","."),'',0,'R'); //Totals
   $this->Ln();
   $stylecount++;  // bump stype count by 1
}