JSHINER Posted February 9, 2009 Share Posted February 9, 2009 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; } } Quote Link to comment https://forums.phpfreaks.com/topic/144499-solved-finding-a-value-in-a-page/ Share on other sites More sharing options...
JSHINER Posted February 9, 2009 Author Share Posted February 9, 2009 I'm sorry - I just realized I need to pull the $500,00 from: <h2 id="cost">$500,000</h2> Quote Link to comment https://forums.phpfreaks.com/topic/144499-solved-finding-a-value-in-a-page/#findComment-758260 Share on other sites More sharing options...
.josh Posted February 9, 2009 Share Posted February 9, 2009 ~<h2 id="cost">(.*?)</h2>~ Quote Link to comment https://forums.phpfreaks.com/topic/144499-solved-finding-a-value-in-a-page/#findComment-758273 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.