Eco preg_match_all

Discussion in 'PHP' started by xchris, Aug 22, 2008.

  1. #1
    I have a huge problem. I'm trying to solve it for like 2 days with no luck. I know how to echo a preg_match_all with foreach, but this time with no luck. I always get an empty array output. I've tested the regex with QuRegExmm and it's working. Anybody want to help

    I'm trying to pregmatch proxy's with port

    here is the code snipplet

    <?php
    $url="http://hotproxy.org.ru/http/index.php";
    $html = file_get_contents($url);
    
    $regex = '/([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+\:[0-9]+)/s';
    preg_match($regex,$htm,$match);
    
    print_r($match);
    ?>  
    Code (markup):
     
    xchris, Aug 22, 2008 IP
  2. cont911

    cont911 Peon

    Messages:
    50
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #2
    you read content into $html, but use $htm
     
    cont911, Aug 22, 2008 IP
  3. xchris

    xchris Peon

    Messages:
    111
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Now i feel like a idiot :mad: . I tough there was a problem with echoing. No wonder the only output was a empty array. Freaking typo. Thanks for your help
     
    xchris, Aug 22, 2008 IP
  4. ghprod

    ghprod Active Member

    Messages:
    1,010
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    78
    #4
    Hm ... why there's no code like [0], [1] and anything else?
     
    ghprod, Aug 22, 2008 IP
  5. cont911

    cont911 Peon

    Messages:
    50
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #5
    xchris, people always make typos, it is quite common error.
    You have created correct regexp and that is good.
    Now you can proceed with your development.
    Focus on positive things! Good luck!
     
    cont911, Aug 22, 2008 IP
  6. NatalicWolf

    NatalicWolf Peon

    Messages:
    262
    Likes Received:
    14
    Best Answers:
    0
    Trophy Points:
    0
    #6
    He uses print_r which recursively prints the array out...He would use $preg[0] or whatever the variable name is after words..
     
    NatalicWolf, Aug 22, 2008 IP
  7. ghprod

    ghprod Active Member

    Messages:
    1,010
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    78
    #7
    o I see :)

    Thnx for correction :D
     
    ghprod, Aug 23, 2008 IP
  8. cornetofreak

    cornetofreak Peon

    Messages:
    170
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    0
    #8
    when printing arrays these are the best mothos

    
    echo "<pre>";
    var_dump($var);
    echo "</pre>";
    
    PHP:
    and
    
    echo "<pre>";
    print_r($var);
    echo "</pre>";
    
    PHP:
    these make he code look really neet so u can see whats in your variables[]
     
    cornetofreak, Aug 24, 2008 IP
  9. ghprod

    ghprod Active Member

    Messages:
    1,010
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    78
    #9
    This one is cool :)

    so it's automatic break lines or whatever . just display the original structure :)
     
    ghprod, Aug 25, 2008 IP