Re: help with fgets

From: Date: Mon, 07 May 2001 18:05:05 +0000
Subject: Re: help with fgets
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-51789@lists.php.net to get a copy of this message
try, $photos[] = $buffer; // without $i in brackets, this means append to the end of the array in the loop, maybe this helps. ----- Original Message ----- From: "tk" <todd@selfassembled.net> To: <php-general@lists.php.net> Sent: 2001. május 7. 19:37 Subject: [PHP] help with fgets > hi. > > i'm trying to read in a text file line by line into an array. i've got > the following code: > $i = 0; > while(!feof ($fp)){ > $buffer = trim(fgets($fp, 4096)); > $photos[i] = $buffer; > $i++; > } > fclose($fp); > > > 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); > > any help would be greatly appreciated > > thanks. > > todd kennedy > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net > For additional commands, e-mail: php-general-help@lists.php.net > To contact the list administrators, e-mail: php-list-admin@lists.php.net >

« previous php.general (#51789) next »