I'm trying to get 'title' from websites, at the moment I'm using preg_match
to get the title but it's very slow to load.
What I have at the moment:
This passes links through to a function:
<?php
foreach($savedLinks as $s)
{
echo "<div class='savedLink'>";
echo "<h5>" . getMetaData($s) . "</h5>";
echo "<a href='" . $s . "'>" . $s . "</a><br />";
echo "</div>";
}
?>
This function grabs the title from each website passed in:
function getMetaData($url)
{
if(!@file_get_contents($url))
{
return "";
}
else
{
if(preg_match('/<title>(.+)<\/title>/',file_get_contents($url),$matches) && isset($matches[1]))
return $matches[1];
else
return "Not Found";
}
}
Is there a fast way to get 'title' from each page?