Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • How to extract website tittle using the given URL

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 174
    Comment on it

    Hello Reader's! If you having a set of given url's you need just the title of them, then you can use the PHP code below to extract title

    <?php
    
    function TitleURL($YourURL){
      $str = file_get_contents($YourURL);
      if(strlen($str)>0){
        $str = trim(preg_replace('/\s+/', ' ', $str)); 
        preg_match("/\<title\>(.*)\<\/title\>/i",$str,$title); // ignore case
        return $title[1];
      }
    }
    //Example:
    echo TitleURL("https://www.wikipedia.org");
    
    ?>
    

    And output will be

    Wikipedia
    

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: