how to merge this 2 script of php??

Discussion in 'PHP' started by sherilpatel, Sep 24, 2010.

  1. #1
    hey,

    I am suppose to fetch the title and url form the below link
    http://www.wikio.com/blogs/top/technology

    I did ir seperatly 1st for title and url....
    below is the script for both

    for title:-

    <?php


    for($number=0;$number<20;$number+=20)
    {
    $titles=array();
    $url="http://www.wikio.com/blogs/top/technology?start={$number}";
    $html=file_get_contents($url);
    while(preg_match('#target="_blank"">(.*?)</a>#', $html, $matches))

    {

    $html=str_replace($matches[0],'',$html);
    $titles[]=$matches[1];

    }

    }
    foreach($titles as $title)
    {
    print "$title\n";
    }
    ?>


    for url:-

    <?php


    for($number=0;$number<20;$number+=20)
    {
    $name=array();
    $url="http://www.wikio.com/blogs/top/technology?start={$number}";
    $html=file_get_contents($url);
    while(preg_match('#target="_blank"">(.*?)</a>#', $html, $matches))

    {

    $html=str_replace($matches[0],'',$html);
    $name[]=$matches[1];

    }

    }
    foreach($name as $name1)
    {
    print "$name1\n";
    }
    ?>
     
    sherilpatel, Sep 24, 2010 IP
  2. sunlcik

    sunlcik Peon

    Messages:
    39
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Are these 2 scripts both the same?
     
    sunlcik, Sep 24, 2010 IP
  3. sherilpatel

    sherilpatel Peon

    Messages:
    2
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    nope...in the preg_match() values are diffrent....one fetches the url or web pages and another fetches the title of url........
     
    sherilpatel, Sep 25, 2010 IP