Mega Code Archive

 
Categories / Php / Strings
 

Getting the title of a remote page

<?php $file = fopen("http://www.php.net/", "r"); if (!$file) {     echo "<p>Unable to open remote file.\n";     exit; } while (!feof($file)) {     $line = fgets($file, 1024);     if (eregi("<title>(.*)</title>", $line, $out)) {         $title = $out[1];         break;     } } fclose($file); ?>