Jump to content

[SOLVED] Finding a Value in a Page


JSHINER

Recommended Posts

If a page has $50,000 in it, how can I use preg_match_all to return that $50,000? I basilly want to return anything that has "$" in front of it.

 

So for example if the page has "The price of this item is $500,000 and it's really nice!" - I want to return "$500,000"

 

I'm trying to following but it is not working:

 

$seed = 'http://www.mysite.com/myPage.html';
$data = file_get_contents($seed);

if(preg_match_all('#^([\$]?)([0-9,\s]*\.?[0-9]{0,2})$#', $data, $match)) {
   
for ($i=0;$i<count($match[0]);$i++) {   
	echo $match;
}
}

Link to comment
https://forums.phpfreaks.com/topic/144499-solved-finding-a-value-in-a-page/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.