This should do what you want using regular expressions.
<?
if ($submit):
$tags = fopen("$data", "r") or die ("Could not open page");
$r = fread($tags, 300);
$r = strtolower($r);
preg_match_all("/<title>.*?\n/", $r, $matches);
$take_out =Array('<', '>', '/', 'title');
$matched =($matches[0][0]);
if(eregi("title", $matched)):
$title = str_replace($take_out, "", $matched);
print"<hr>This is the page title :: <b>$title</b>";
else:
print"<b>Sorry, I could not get the title for this page</b>";
endif;
else:
print"<html><title>Find Title</title>
<body>
<form method=\"POST\" action=\"$PHP_SELF\">
<table width=\"300\" border=\"0\" align=\"center\">
<tr><td>Enter URL !!</td></tr>
<tr><td><input type=\"text\" name=\"data\" value=\"http://www.homestarrunner.com\" size
=\"34\"></td></tr>
<tr><td><input type=\"submit\" name=\"submit\" value=\"Get Title\"></td></tr>
</table>
</form>
</body>
</html>";
endif;
?>