Following regex works fine for me for most of url. But in case of few url, it does not give title, though source code has title.
$data = file_get_contents($url);
$title = get_title($data);
echo $title;
function get_title($html)
{
return preg_match('!<title>(.*?)</title>!i', $html, $matches) ? $matches[1] : '';
}
Here is the demo : DEMO