R
R
rednager2014-05-12 18:46:33
PHP
rednager, 2014-05-12 18:46:33

How to pull the title from someone else's page?

Actually, I messed up the script, but something doesn't work, tell me, please :-D
11663adb68ec4cc58f82eb5024c15e92.png
I've never done a parser, I'm new to PHP :-)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
Eugene Obrezkov, 2014-05-12
@rednager

Actually muddied the answer, but something was not marked with a solution :-D

function getTitle($Url){
    $str = file_get_contents($Url);
    if(strlen($str)>0){
        preg_match("/\<title\>(.*)\<\/title\>/",$str,$title);
        return $title[1];
    }
}

echo getTitle("http://www.washingtontimes.com/");

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question