View Full Version : Reading a txt file one line at a time.

09-21-2005, 04:18 PM
I ran a quick search of the forums and google and cannot find a site telling how this would be done.

Basically i'm parsing a text file looking for key terms. The text file will always have different content however it will be structured the same and have the same key terms. i want to search the file line by line (dumping the line into a string) then using regEx see if it's the line of data i want.

I can write the regEx, it's the loop for the reading the file i'm having troubles with.

if anyone can write me up a quick example of how this is done, or point me to a tutorial i would appreciate it.

09-21-2005, 04:21 PM

09-21-2005, 05:47 PM
I'd say fopen()/fgets() (in loop)/fclose() would be better if the file is large.

09-21-2005, 09:03 PM
the files are all under 25kb, file($path) works for what i am doing.