Re: help with fgets

From: Date: Mon, 07 May 2001 19:01:06 +0000
Subject: Re: help with fgets
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-51799@lists.php.net to get a copy of this message
On Monday 07 May 2001 19:37, tk wrote: > when i echo $buffer to the screen it prints out hte content of hte file > line by line > if i echo $photos[i] to the screen it just prints out random numbers > and not the content i'd expect > > (the code i'm using to do this is: > > $i = 0; > while(!feof ($fp)){ > $buffer = trim(fgets($fp, 4096)); > echo $buffer."<br>"; > $photos[i] = $buffer; > echo $photos[i]."<br>"; > $i++; > } > fclose($fp); for these two echos, the printed result should be absolutely identical. Check the HTML source of the generated page to be sure, create a minimal PHP file that only contains these lines (plus the fopen of course) to see if the problem persists in that simple case and if there still are differences report it as bug. AH! Got it. replace $photos[i] with $photos[$i] Right now it interprets the i in the brackets as bareword, assumes a string is meant and thus interprets it as $photos ['i']. -- Christian Reiniger LGDC Webmaster (http://sunsite.dk/lgdc/) Error 032: Recursion error - see error 032

« previous php.general (#51799) next »