Results 1 to 3 of 3

Thread: [RESOLVED] PHP Preg_Match Problem.

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    May 2008
    Location
    >> ( ҉ )
    Posts
    413

    Resolved [RESOLVED] PHP Preg_Match Problem.

    PHP Code:
    <?php
    $pattern 
    '[1-9]';
    $site "http://vbforums.com/";
    $file file_get_contents($site) or die(":O ERROR IN PAGE SOURCE");
    preg_match($pattern$file$matches);
    print_r($matches[1]);
    ?>
    I tried preg_match_all too, but it cannot find any kind of numbers from page. Only what i find is empty white PHP page where's nothing. So (no results).

    Thanks if someone can help.

  2. #2
    PowerPoster
    Join Date
    Sep 2003
    Location
    Edmonton, AB, Canada
    Posts
    2,629

    Re: PHP Preg_Match Problem.

    that pattern will not match anything. you don't have any parenthesis to tell the regex engine to capture anything. try:

    PHP Code:
    $pattern '/([1-9])/'
    if you still get nothing, try echoing $file after you define it (using <xmp>) to make sure the page is being returned correctly:
    PHP Code:
    <xmp>
    <?php
      $file 
    file_get_contents($site);
      echo 
    $file;
    ?>
    make sure you turn on error reporting, too, so that you might be able to see any errors that are going on.

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    May 2008
    Location
    >> ( ҉ )
    Posts
    413

    Re: PHP Preg_Match Problem.

    Thanks much kows.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width