您好我正在使用FPDF
生成PDF
文件。我正在foreach
使用Cell
FPDF
函数显示每个项目。现在我有一个条件语句来获取iteration
中的最后一个foreach
或最后一项,并在其中添加一个特定值。之后,我需要用新值覆盖(显示)最后一次迭代。
Image Above是我正在显示的项目。最后一项是最后一次迭代。最后一项的第一个值是263.50
,之后得到它,因为它是最后一次迭代。我在其上添加.01
值为263.51
。
我可以显示新值,但旧值仍然存在。
这是我的示例代码
$this->SetXY(29, $y);
$this->SetFont('Arial','',8.5);
$this->Cell(18,4,$value_of_ins = str_replace(',', '', number_format($inscost_conv, 2)),1,0,'R'); // this line is to display the items
if ($i == $len - 1) { // to get the last iteration
$value_of_ins = $value_of_ins + 1;
$this->SetXY(29, $y);
$this->SetFont('Arial','',8.5);
$this->Cell(18,4,$value_of_ins,1,0,'R'); // display the last item with new value
}
$i++;
答案 0 :(得分:0)
我想你不应该写入最后一个值,直到你加1。像这样:
$this->SetXY(29, $y);
$this->SetFont('Arial','',8.5);
$value_of_ins = str_replace(',', '', number_format($inscost_conv, 2));
if ($i == $len - 1) {
$value_of_ins += 1
}
$this->Cell(18,4,$value_of_ins,1,0,'R'); // this line is to display the items