...

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



rlemon
09-21-2005, 03: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.

NancyJ
09-21-2005, 03:21 PM
http://uk.php.net/function.file

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

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



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum