This works too.

$fp = fopen($filename,'r');
        //do what you need to do with $line

Robbert van Andel 

-----Original Message-----
From: Rasmus Lerdorf [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, November 19, 2002 11:44 AM
To: Kelly Meeks
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);


On Tue, 19 Nov 2002, Kelly Meeks wrote:

> here's an example of a text file I need to read...
> abcd|test1|morevalues|otherstuff
> I believe each line is seperated by a carriage return.
> How can I read this in one line at a time in to a variable?
> I'm assuming that I could then explode that variable using the pipe as the
seperator text?
> Kelly

PHP General Mailing List (
To unsubscribe, visit:

 "The information transmitted is intended only for the person or entity to
which it is addressed and may contain confidential and/or privileged
material. Any review, retransmission, dissemination or other use of, or
taking of any action in reliance upon, this information by persons or
entities other than the intended recipient is prohibited. If you received
this in error, please contact the sender and delete the material from all

Reply via email to