Re: Reading Text file by line

From: Date: Mon, 24 Feb 2003 16:37:32 +0000
Subject: Re: Reading Text file by line
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-136936@lists.php.net to get a copy of this message
Depends on what OS you are: Windows: Search for \n\r (or chr(13) . chr(10)) Unix/linux: Search only for \n (or chr(13)) MAC: Search for only \r (or chr(10)) If you want to READ line by line instead of Exploding your complete content, use this: $myLine = fgets($myFilePointer, 1048576) The 2 problem are that if your line is longer than 1 meg (That means a line of 1048576 characters long without a EOL) then it will not read everything. And the 2nd problem is the EOL (\n\r, \n or \r) is kept with the line, so you have to also implement the code to strip out the \n and/or \r from the end of line. Mathieu Dumoulin "Anthony" <atampone@attechcomputer.com> a écrit dans le message de news: 20030224163015.27988.qmail@pb1.pair.com... > I need to read a text file by line, if I open the file and use fgets() then > it doesn't pick up the EOL corretly. So I was planning on reading the whole > file in with fread() and then breaking it up by EOL characters. My question > is, how do I do it? What character do I search for in the string? Anyone > have a simple example on how to do this? Thanks. > >

« previous php.general (#136936) next »