我这样做对吗?我正在尝试调用数组中的最后一个元素:$initr
我的 IF 语句需要专门询问数组中的每个元素是否是最后一条记录。如果结果为真,它将在该位置打印条形码。(IF条件之后的所有内容,你可以忽略)。
<?php
$initr = $this->record;
$last = end($initr); // Put something like this at the top...
// Then something like this for each record. (I don't know if this is correct syntax)...
if ($initr[4] == $last) {$content=$view->pdf->write1DBarcode('01234567094987654321-'.str_replace("-","",$content), 'IMB', .24, '1.58', '', 0.15, 0.015, $barstyle, '');}
elseif ($initr[5] == $last) {$content=$view->pdf->write1DBarcode('01234567094987654321-'.str_replace("-","",$content), 'IMB', 3, '1.58', '', 0.15, 0.015, $barstyle, '');}
elseif ($initr[6] == $last) {$content=$view->pdf->write1DBarcode('01234567094987654321-'.str_replace("-","",$content), 'IMB', 3, '1.58', '', 0.15, 0.015, $barstyle, '');}
?>