Forum Moderators: coopster
$pattern = 'Trader Rating: (<a href="itrader.php?u=1111">122</a>)';
//$pattern = preg_quote($pattern);
$pattern = '/' . $pattern .'/';
echo $pattern;
preg_match($pattern, $page, $matches);
print_R($matches);
Right now it prints out an empty array, $page is just an html page. I need to match the pattern. With 1111 being any number and 122 matching any number. Then I need to pull the 122 number out of it so I know what that number is.
[edited by: eelixduppy at 1:52 am (utc) on Jan. 20, 2008]
[edit reason] disabled smileys [/edit]
You should not pass the html page name, but its content. So, use file_get_content() function to read the html page code into a string.
Lets suppose $page looks like:
$page = 'Trader Rating: <a href="itrader.php?u=1111">122</a>';
Than, your pattern will be:
$pattern = "/Trader Rating: \<a href=\"itrader.php\?u=\d{1,}\">(\d{1,})<\/a>/";
and the $matches will contain this data:
Array
(
[0] => Trader Rating: <a href="itrader.php?u=1111">122</a>
[1] => 122
)
The result you are looking for is stored at $matches['1'] element.