echo "<table><tr>"; while(list(,$fname) = each($file_list)) { if(!($cnt % 4) && $cnt++!=0) { echo "</tr><tr>"; } echo "<td>$fname</td>"; } echo "</tr></table>";
Didn't actually test that, but it should be close ... the important piece is ($cnt % 4) ... modulo arithmetic is your friend. That and thinking in terms of cells, not rows. > Example: > $image_dir = opendir("../images/bullets/"); > while ($file = readdir($image_dir)) { $file_list[] = $file; }; > > Now $file_list[] has some number a file names. I want print 4 file names > into a row. Each file name has to be in its on cell. > > <table> > <tr> <td>FILE 0</td> <td>FILE 1</td> <td>FILE 2</td> <td>FILE 3</td> </tr> > <tr> <td>FILE 4</td> <td>FILE 5</td> <td>FILE 6</td> <td>FILE 7</td> </tr> > </table> > > I would image I would use a for loop, but I cant figure it out. > Can somone assist me ? > > Thanks, > Steve > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > To contact the list administrators, e-mail: [EMAIL PROTECTED] > -- Hank Marquardt <[EMAIL PROTECTED]> http://web.yerpso.net GPG Id: 2BB5E60C Fingerprint: D807 61BC FD18 370A AC1D 3EDF 2BF9 8A2D 2BB5 E60C *** Web Development: PHP, MySQL/PgSQL - Network Admin: Debian/FreeBSD *** PHP Instructor - Intnl. Webmasters Assn./HTML Writers Guild *** Beginning PHP -- Starts January 7, 2002 *** See http://www.hwg.org/services/classes -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]