[PHP] Files question
How can i read all files line by line? I am running windows. I know that there is then a \r\n but i don't know how to extract them... Can you help me? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Files question
[snip] How can i read all files line by line? I am running windows. I know that there is then a \r\n but i don't know how to extract them... Can you help me? [/snip] start with http://www.php.net/fopen -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Files question
Now sorry... I already know to use fopen... I want a script that parses all lines from a file... Just like a loop that with every time it is executed, it echos a line from the file... (this is just a example... else i was using file_get_contents and nl2br...) Jay Blanchard [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] [snip] How can i read all files line by line? I am running windows. I know that there is then a \r\n but i don't know how to extract them... Can you help me? [/snip] start with http://www.php.net/fopen -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Files question
[snip] Now sorry... I already know to use fopen... I want a script that parses all lines from a file... Just like a loop that with every time it is executed, it echos a line from the file... (this is just a example... else i was using file_get_contents and nl2br...) [/snip] 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 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Files question
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 = $valuebr; } HTH -- Ray -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php