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
    • 181
    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

    1. <?php
    2.  
    3. function TitleURL($YourURL){
    4. $str = file_get_contents($YourURL);
    5. if(strlen($str)>0){
    6. $str = trim(preg_replace('/\s+/', ' ', $str));
    7. preg_match("/\<title\>(.*)\<\/title\>/i",$str,$title); // ignore case
    8. return $title[1];
    9. }
    10. }
    11. //Example:
    12. echo TitleURL("https://www.wikipedia.org");
    13.  
    14. ?>

    And output will be

    1. Wikipedia

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Reset Password
Fill out the form below and reset your password: