I'm trying to get the title of articles from websites. It works for some website but not for all.
I've tried with BBC news and it works. When I tried with NYtimes article, it doesnt give a good title even though I can see in the source code that the title tag exists with the right title.
Here is the code
$titre = preg_match('/<title>(.+)<\/title>/',file_get_contents($url),$matches);
echo $matches[1];
when I try http://www.bbc.com/news/business-30512079 it works
when I try enter link description here it gives Log In - The New York Times