Getting the title of a remote page : eregi « String « PHP






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);
?>
  
  








Related examples in the same category

1.Case-insensitive Pattern Matching
2.eregi() function searches a string for another string.
3.eregi.php