Jump to content

Loop from array


porta325

Recommended Posts

$cell = 0;

echo '<table><tr>';

foreach ($results as $result)

{

    echo '<td>'.$result.'</td>';

    $cell++;

    if ($cell == 2)

    {

          echo '</tr><tr>';

          $cell = 0;

    }

}

echo '</tr></table>';

 

I have something like this and i wanna display an array on rows 3 by 3.

EX:

1  2  3 

4  5  6 

7  8  9

Link to comment
https://forums.phpfreaks.com/topic/56522-loop-from-array/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.