file read operation
Moderator: General Moderators
-
jaymoore_299
- Forum Contributor
- Posts: 128
- Joined: Wed May 11, 2005 6:40 pm
- Contact:
file read operation
How do you read a specific line from a file without putting the whole file into memory first than searching for that line?
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?
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?