Re: for() question

From: Date: Tue, 29 Apr 2003 09:25:19 +0000
Subject: Re: for() question
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-145604@lists.php.net to get a copy of this message
for starters you are counting an integer. $number_of_dirs = count($dir_list); $i< count($number_of_dirs); I think you meant to do, but I dunno: $i< $number_of_dirs; -- Jason k Larson Chris Blake wrote:
Greetigns learned PHP(eople), Why is this code only returning one value to my <td> ? directories.txt contains 10 entries. ----------------------------------------------------------- <?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< count($number_of_dirs); $i++)
      {
      //Get each line in text file and place in an array
      $line = explode( "\t", $dir_list[$i]);
      print '<tr>' . "\n";
      print '  <td>' . ($line[$i]) . '</td>' . "\n";
      print '</tr>' . "\n\n";
      }
     print '</table>' . "\n";
?>     ----------------------------------------------
This is probably just a small oversight on my behalf but it`s driving me closer to the bottle of Jack Daniels I have nearby. Thanks


« previous php.general (#145604) next »