Re: [PHP] how to read text file one line at a time

2002-11-19 Thread Marco Tabini
There are a couple of ways: - If the file is small enough, I suppose you could use the http://ca.php.net/manual/en/function.file.php file function, which loads the file in array (one element per line). - If the file is bigger, you can use the normal fopen() functionality and then use

Re: [PHP] how to read text file one line at a time

2002-11-19 Thread Jason Wong
On Wednesday 20 November 2002 03:45, Kelly Meeks wrote: here's an example of a text file I need to read... abcd|test1|morevalues|otherstuff efghijklm|a;kd;laskf;alskdjf;alskdf;askldjasldkf|;askd;lakjl;asdf|al;sdjf;a lf I believe each line is seperated by a carriage return. How can I read

RE: [PHP] how to read text file one line at a time

2002-11-19 Thread Van Andel, Robert
PROTECTED] Subject: Re: [PHP] how to read text file one line at a time $array = file($filename); Each line of the array will have a line of your file. Or, if you want to do it line by line: $fp = fopen($filename,'r'); while(!feof($fp)) { $line = fgets($fp); } fclose($fp); -Rasmus

Re: [PHP] how to read text file one line at a time

2002-11-19 Thread Nick Eby
even further, instead of using fgets() to get each line and then exploding it, you can use fgetcsv() which reads the line and breaks it into chunks by any delimiter, returning the chunks in an array. $fp = fopen($filename, r); while (!feof($fp)) { $line = fgetcsv($fp, 9, |); ... }