Replies: 1   Views: 154
How do i loop to create a table with multiple value

Posted by admin  · 23-11-2022 - 09:32


Please note that this question is not related to phpdocx but to PHP. PHP throws a warning if you try to read a non-existing array key/position/value.

You need to generate a multidimensional PHP array from your data. For example, using a $dataValues array as data source:

$tableData = array();
foreach ($dataValues as $dataValue) {
    $rowData = array(
        'VAR_1' => $dataValue['val_1'],
        'VAR_2' => $dataValue['val_2'],
        'VAR_3' => $dataValue['val_3'],

    $tableData[] = $rowData;

How to do the exact loop (iteration) depends on the data you are working with. The problem with your code is that you are accesing fixed array keys, and you should get them dynamically to know the exact number of rows to do the loop and generate the correct array.

On you can read PHP documentation about arrays.