|
-
Mar 4th, 2010, 02:33 PM
#1
Thread Starter
Hyperactive Member
[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.
-
Mar 4th, 2010, 04:51 PM
#2
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.
-
Mar 5th, 2010, 03:10 PM
#3
Thread Starter
Hyperactive Member
Re: PHP Preg_Match Problem.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|