searching string for a certain word!!

Discussion in 'PHP' started by jigen7, Sep 19, 2007.

  1. #1
    i want to search most of the string the word google for examle a string that contains www.news.google.com/blah blah or www.images.googel.com/blah blah i want them to be excluded in my search so that i can find the real site
    i have here the coding whre $all_url[] array contains the links/url and i only want to display the link that doesnt start with number for example htt[://77787etc and links that does not contain any google in the string only the valid urls i wnat to display so can anyone help me simplify my coding?

    $x= $counter;
    while (++$x < 200){

    $all_url_edit = $all_url[$x];

    if ($all_url_edit >= 'http://a'){
    $compare1 = strcmp(substr($all_url_edit,0,24),'http://images.google.com');
    $compare2 = strcmp(substr($all_url_edit,0,23),'http://video.google.com');
    $compare3 = strcmp(substr($all_url_edit,0,22),'http://news.google.com');
    $compare4 = strcmp(substr($all_url_edit,0,24),'http://groups.google.com');
    $compare5 = strcmp(substr($all_url_edit,0,21),'http://www.google.com');
    $compare6 = strcmp(substr($all_url_edit,0,25),'http://adwords.google.com');

    if ($compare1 != 0 && $compare2!=0 && $compare3!=0 && $compare4!=0 && $compare5 !=0 && $compare6 !=0){
    //echo $compare;
    //echo "<a href='$all_url_edit' target=_blank>$all_url_edit</a>";
    //echo "<br>";
    $urls[] = $all_url_edit;
    }


    }
    }
     
    jigen7, Sep 19, 2007 IP
  2. phper

    phper Active Member

    Messages:
    247
    Likes Received:
    17
    Best Answers:
    0
    Trophy Points:
    60
    #2
    im not sur wat u askin wih al teh mispelin and u culdnt be bothred to use punctutation so scrw u lazie sshol
     
    phper, Sep 19, 2007 IP
  3. msaqibansari

    msaqibansari Peon

    Messages:
    84
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Your question is confusing.... Please define more to get answer.
     
    msaqibansari, Sep 20, 2007 IP
  4. phantom

    phantom Well-Known Member

    Messages:
    1,509
    Likes Received:
    32
    Best Answers:
    0
    Trophy Points:
    140
    #4

    OMG that was so funny .........I almost fell out of my chair. Thanks for that!
     
    phantom, Sep 21, 2007 IP
  5. krt

    krt Well-Known Member

    Messages:
    829
    Likes Received:
    38
    Best Answers:
    0
    Trophy Points:
    120
    #5
    Is this simple enough?
    It removes links starting with a number or if the URL is google.com or a subdomain of it.
    $x = $counter;
    while (++$x < 200) {
      if (preg_match('~http://(www\.)?([0-9]|(.+\.)?google\.com)~', $all_url[$x])
        unset($all_url[$x]);
    }
    // $all_url is now an array with the unwanted URLs removed
    
    PHP:
     
    krt, Sep 21, 2007 IP
  6. jigen7

    jigen7 Peon

    Messages:
    42
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    wow thx!! i wish im that good in regular expression
     
    jigen7, Sep 21, 2007 IP