[nycphp-talk] Reading just a couple lines of a file?
ben at projectskyline.com
Wed Mar 26 11:39:11 EDT 2008
Performance: Yeah, you don't have to hold the entire file in memory. Use
fopen/fread and iterate through
with a buffer size.
> Is there a performance benefit and way to read just the first few lines
> of a 5k-10k file? I'm dealing with 20-300 files at a time.
> Pseudo code would look something like this:
> DirectoryIterator (Thank you PHP CookBook!)
> for each file:
> open file to read
> match $title to stuff between title HTML tags
> put $title into an array based on catagory
> put filename into an array (index matches the $title array)
> close file
> Go through the $title arrays in Catagory sequence
> Echo $Catagory
> sort $title array alphabetically
> echo "a href filename" $title "/a"
> New York PHP Community Talk Mailing List
> NYPHPCon 2006 Presentations Online
> Show Your Participation in New York PHP
More information about the talk