Jump to content

print part of an array


TheNix

Recommended Posts

It would be much easier if you gave an exampe of the code you want to use to display these in. You say you wnat 10 names in each table, but did you mean 10 names in each row of a table?

 

Anyway here is a quick example of how to do it with separate tables (not tested):

<?php

$count = 1;

foreach ($names as $name)
{

  if ($count==1)
  {
    echo "<table><tr>";
  }

  echo "<td>$name</td>";
  $count++;

  if ($count>10)
  {
    echo "</tr></table>";
    $count = 1;
  }

}

if ($count!=1)
{
  echo "</tr></table>";
}

?>

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.