Obtaining the HTML Title of a URL

Here’s a little code snippet that allows you to grab the Title tag if you have a URL in php:

$url = "http://www.folksonomy.org";
$page = file($url);
$page = implode("",$file);

if(preg_match("/<title>(.+)<\/title>/i",$page,$t))
    print "$url has the title: $t";
else
    print "No title was found";