Checking title of 10 URL's

Discussion in 'PHP' started by imnajam, Feb 19, 2008.

  1. #1
    Hi,

    I have a textbos in which I have 10 URL's, my aim is to retrieve Title information of all these 10 URL's and than store them into db.
    Can anybody help me in finding a way to retrieve title of a URL ?

    Thanks in advance
     
    imnajam, Feb 19, 2008 IP
  2. jayshah

    jayshah Peon

    Messages:
    1,126
    Likes Received:
    68
    Best Answers:
    1
    Trophy Points:
    0
    #2
    From http://www.zend.com//code/codex.php?ozid=233&single=1

    
    <?php
    function get_title_tag($chaine){
        $fp = fopen ($chaine, 'r');
        while (! feof ($fp)){
             $contenu .= fgets ($fp, 1024);
             if (stristr($contenu, '<title>' )){
                     break;
                    }
             }
        if (eregi("<title>(.*)</title>", $contenu, $out)) {
            return $out[1];
            }
        else{
            return false;
            }
        }
    ?>
    
    PHP:
    Usage:
    
    <?php
    echo get_title_tag('http://www.zend.com');
    ?>
    
    PHP:
    Jay
     
    jayshah, Feb 19, 2008 IP
    imnajam likes this.
  3. imnajam

    imnajam Well-Known Member

    Messages:
    2,389
    Likes Received:
    113
    Best Answers:
    0
    Trophy Points:
    185
    #3
    Excellent, this is exactly what I was looking for:)

    Thank you Jay.
     
    imnajam, Feb 19, 2008 IP
  4. jayshah

    jayshah Peon

    Messages:
    1,126
    Likes Received:
    68
    Best Answers:
    1
    Trophy Points:
    0
    #4
    You're very welcome :)

    Thanks for the rep.

    Jay
     
    jayshah, Feb 19, 2008 IP