Question

I'm trying to populate a table with the function writehtmlcell using a foreach loop. I'm getting errors like null or something and invalid arguments supplied for foreach. Any idea?

The code is shown below.

$get_output = array(one, two, three, four, five);
$ctrword = 0;
$html .="<table>";
foreach ($get_output as $key) {
    $ctrword++;
    if(($ctrword % 5) == 0)
    {
       html .= "<tr>";

    }
    if(($ctrword%5)==1)
    {
       $html .= "<td>".$key."</td>";  

    }
    if(($ctrword%5)==5) 
    {
       $html .= "</tr>";

    }

 }          

$html .= "</table>";
pdf->WriteHtmlCell(0,0,'','',$html,1);
Was it helpful?

Solution

a)

html .= "<tr>";  // missing $html

b) if one,two... are not constant ,use below code

 $get_output = array('one', 'two', 'three', 'four', 'five');
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top