"get title of website via link" Answer’s


My answer is expanding on @AI W's answer of using the title of the page. Below is the code to accomplish what he said.


function get_title($url){
  $str = file_get_contents($url);
    $str = trim(preg_replace('/s+/', ' ', $str)); // supports line breaks inside <title>
    preg_match("/<title>(.*)</title>/i",$str,$title); // ignore case
    return $title[1];
echo get_title("http://www.washingtontimes.com/");



Washington Times - Politics, Breaking News, US and World News

As you can see, it is not exactly what Google is using, so this leads me to believe that they get a URL's hostname and match it to their own list.

http://www.washingtontimes.com/ => The Washington Times

Wednesday, March 31, 2021
answered 11 Months ago
Only authorized users can answer the question. Please sign in first, or register a free account.
Not the answer you're looking for? Browse other questions tagged :