Re: for() question

From: Date: Tue, 29 Apr 2003 09:51:59 +0000
Subject: Re: for() question
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-145614@lists.php.net to get a copy of this message
An excellent suggestion, thanks Greg. Greg Wiley wrote:
Chris, Is this what you really meant? <?php
    $dir_list = file("directories.txt");
    $number_of_dirs = count($dir_list);
     if (!$dir_list) {
       print '<p>' . "\n" . '<strong>Directory File Not Found.</strong>' . "\n"
. '</p>';
       exit;
    }
     print "\n" . '<table border="1" bordercolor="navy">' . "\n";
    print '<tr bgcolor="lightgrey">' . "\n";
    print '  <td>Main Menu</td>' . "\n";
    print '</tr>' . "\n\n";
     for ($i = 0; $i < $number_of_dirs; $i++)       {
       //Get each line in text file and place in an array
       $line = explode( "\t", $dir_list[$i]);
       print '<tr>' . "\n";
       for ($j = 0; $j < count($line); $j++) {
          print '  <td>' . ($line[$j]) . '</td>' . "\n";
       }
       print '</tr>' . "\n\n";
    }
     print '</table>' . "\n";
It's difficult to know for sure as I'm only guessing at what the format of directories.txt is and what the resultant table should look like. Cheers, Greg.


« previous php.general (#145614) next »