RE: [PHP] Files question
| From: | Ray Hunter | Date: | Thu, 30 Oct 2003 14:56:48 +0000 |
| Subject: | RE: [PHP] Files question | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-168156@lists.php.net to get a copy of this message | ||
> Well, Bas, the fopen and it's associated manual pages describe just how
> to do this. Basic example
>
> $theFile = fopen("myfile.foo", "r"); //open the file for reading
> while(!feof($theFile)){ // while the file is not at the end of the file
> $theLine = fgets($theFile, 1024); // get a line, specify a
> length
> echo $theLine; // print out the line you just got
> } //close the while loop
http://us2.php.net/manual/en/function.file.php
Using file will read each line of a file into an element of the returned
array. then you can loop through the array and pull out line by
line...example:
$lines = file( "somefile.txt" );
foreach( $lines as $line => $value ) {
echo "$line = $value<br>";
}
HTH
--
Ray