i am getting the title of a page using the following
$urlContents = file_get_contents("$url");
preg_match("/<title>(.*)<\/title>/i", $urlContents, $matches);
the problem i am having is one of the sites the title is on 3 lines
<head id="head"><title>
title goes here
</title><meta name="description" content="meta description" />
this is for a basic onpage seo tool i am writing, is there a better way i can get the title of a page?
Thank you
How about just using plain js
var title = document.title
Or jquery
var title = $("head title")[0];