TCPDF - 以两列布局循环数据

The*_*per 4 php foreach tcpdf

我使用 TCPDF,目前我在两列中列出数据,使用array_chunk 它可以正常工作。但我需要数据显示在第一列然后第二列,见下文:

Currently:
    1   2
    3   4
    5   6
    7   8
    9   10
Should be:
    1   6
    2   7
    3   8
    4   9
    5   10
Run Code Online (Sandbox Code Playgroud)

这是代码:

<?php   $array = range(1, 50);?>
<table nobr="true" cellpadding="2">
     <?php foreach (array_chunk($array, 2) as $a) { ?>
        <tr>
        <?php foreach ($a as $array_chunk) { ?>
           <td><?php echo $array_chunk; ?></td>
            <?php
         } ?>
       </tr>
       <?php }    ?>
</table>
Run Code Online (Sandbox Code Playgroud)

我的第二个查询(复杂)如果有超过 30 行我需要能够使用 $pdf->AddPage(); 并在下一页继续。

The*_*per 5

TCPDF - 支持多列,这是我用来解决我的问题的wat:

$pdf->AddPage();
$pdf->resetColumns();
$pdf->setEqualColumns(2, 84);  // KEY PART -  number of cols and width
$pdf->selectColumn();               
$content =' loop content here';
$pdf->writeHTML($content, true, false, true, false);
$pdf->resetColumns()
Run Code Online (Sandbox Code Playgroud)

代码将添加自动分页符并继续到下一页。