if its valid xhtml you could always use SimpleXML, and just get the title.
http://www.php.net/SimpleXML


csnyder wrote:
On 3/26/08, Ben Sgro <[EMAIL PROTECTED]> wrote:
  
 Hello,

 Performance: Yeah, you don't have to hold the entire file in memory. Use
 fopen/fread and iterate through
 with a buffer size.


 - Ben
    

And since you're searching for something specific, you can even just
go line by line using fgets() till you find what you want:

$fp = fopen( $file, r );
while( !feof($fp) ) {
  $line = fgets( $fp );
  if ( strpos( $line, '<title' ) !== FALSE ) {
    break;
  }
}
if ( !feof( $fp ) ) {
  // get title out of $line here
}

Since you're working with big files, it makes sense to build a better
limit into the while loop, to bail out if the title isn't found after
99 lines or something.

  

_______________________________________________
New York PHP Community Talk Mailing List
http://lists.nyphp.org/mailman/listinfo/talk

NYPHPCon 2006 Presentations Online
http://www.nyphpcon.com

Show Your Participation in New York PHP
http://www.nyphp.org/show_participation.php

Reply via email to