Page 1 of 1
file read operation
Posted: Sat May 28, 2005 10:38 am
by jaymoore_299
How do you read a specific line from a file without putting the whole file into memory first than searching for that line?
Posted: Sat May 28, 2005 11:24 am
by JAM
This does calssify into the "read the entire file into memory" but as alot of people still use fopen/fread functions to handle reading files, I thought I'd at least mention it.
If you use
file() you read the file into an array and by using the keys you have the line numbers (starting at 0 tho). A personal favourite. Easier than fopen/fread and/or readfile():
Still not good enough?