• Welcome to Overclockers Forums! Join us to reply in threads, receive reduced ads, and to customize your site experience!

PHP match functions

Overclockers is supported by our readers. When you click a link to make a purchase, we may earn a commission. Learn More.

phatmonkey

New Member
Joined
Feb 28, 2004
Location
UK
Ok, what I am basically trying to do is to get an amount of hits from an external html page, and putting it into a variable. I know a piece of unique start code in front of the number, and a some code that goes after the number. I came up with this:

// Open the page
$handle = fopen($hitsurl,"r");

// Read it and put it into a variable
$hitpage = fread($handle,100000);

// Sort out the codestart/ends to take out anything that affects the code
$codestartfixed = str_replace("/", "\/", $codestart);
$codeendfixed = str_replace("/", "\/", $codeend);

// Look through the page to find the number between the start and end code
preg_match("/$codestartfixed(.*)$codeendfixed/isU",$hitpage,$match);

echo " - $match[0] hits";

$codestart = code in front of number
$codeend = code after number
$hitsurl = the url of the page
Obviously assuming its smaller than 100k.

But this echos "- hits". What have i done wrong?
 
Back