[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.
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.
Re: PHP Preg_Match Problem.