View Full Version : Read Dir help

12-09-2010, 06:00 PM
With the code below. how could I make it so that if after it reads five out of the ten folders it goes to a new line or table??

//Open directory
echo "<table cellpadding=\"0\" cellspacing=\"0\" ><tr>";
//List items in directory
while(($directory=readdir($location)) !== false) {

//Directory filter
if($directory!= '.' && $directory!= '..'){

//Include index files from directories
echo "<td valign=\"top\" align=\"center\"><div id='".$directory."'>"; include($directory.'/index.php'); echo "</div></td>";}}}
echo "</tr></table>";

Thanks, S.

12-09-2010, 11:11 PM
Declare an array, push all the entries into the array with array_push(), course over the array with a for loop and suitable conditional statements.

12-10-2010, 01:01 AM
too many ways : , simplistic would be as below & just echo a </tr><tr> every 5 iterations, if the total count is not divisible by 5 grab $tr value and make up the empty space at the end.

echo '<table><tr>';
/**the relevant bit*/
echo '</tr><tr>';
echo "<td>$x</td>";
echo '</tr></table>';

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum