Porl123 Posted February 17, 2009 Share Posted February 17, 2009 I've got this page of html from a page I'm logged in and retrieving using curl but I don't have a clue what pattern I'd need to use with preg_match_all to get the data I need. The data I need is a sum of money and the sentence I need to get it from is this- The maximum bet is set at <b>$150,000</b>.<br> It's for a casino maximum bets page I'm making for a site I'm on. If anyone can help me I'd greatly appreciate it. Thanks! Link to comment https://forums.phpfreaks.com/topic/145576-solved-preg_match_all-patterns/ Share on other sites More sharing options...
JonnoTheDev Posted February 17, 2009 Share Posted February 17, 2009 if(preg_match('%The maximum bet is set at <b>\\$([0-9,]+)</b>\\.<br>%', $subject, $regs)) { $result = $regs[0]; } print $result; Link to comment https://forums.phpfreaks.com/topic/145576-solved-preg_match_all-patterns/#findComment-764270 Share on other sites More sharing options...
Porl123 Posted February 17, 2009 Author Share Posted February 17, 2009 That works but do you know how I'd get the bare number? Link to comment https://forums.phpfreaks.com/topic/145576-solved-preg_match_all-patterns/#findComment-764271 Share on other sites More sharing options...
Porl123 Posted February 17, 2009 Author Share Posted February 17, 2009 Woops, ignore that, it works great. Thanks man I owe you one Link to comment https://forums.phpfreaks.com/topic/145576-solved-preg_match_all-patterns/#findComment-764274 Share on other sites More sharing options...
premiso Posted February 17, 2009 Share Posted February 17, 2009 <?php $string = "The maximum bet is set at <b>$150,000</b>.<br> and The maximum bet is set at <b>$25,000</b>.<br>"; preg_match_all("~maximum bet is set at <b>\\$(.+?)</b>~si", $string, $matches); foreach ($matches[1] as $bets) { echo $bets . "<br />"; } die(); ?> Whether or not that is the best way to do it...it works with the example you gave us.. Link to comment https://forums.phpfreaks.com/topic/145576-solved-preg_match_all-patterns/#findComment-764275 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.