smilesmita Posted August 30, 2007 Share Posted August 30, 2007 hi there: i have somethig like this in my buff: <TD>Average Rate</TD><TD align="right">31.09</TD> i want to apply preg_match to get the value 31.09 out..how do it do it?> please help! -smita Quote Link to comment https://forums.phpfreaks.com/topic/67347-preg_match/ Share on other sites More sharing options...
Hybride Posted August 30, 2007 Share Posted August 30, 2007 Try this: $data = file_get_contents("websiteurl.php"); if (preg_match('/Average Rate[^0-9]*([0-9,]+)/i', $data, $regs)){ $data_result = $regs[1]; } echo $data_result; Quote Link to comment https://forums.phpfreaks.com/topic/67347-preg_match/#findComment-337884 Share on other sites More sharing options...
GingerRobot Posted August 30, 2007 Share Posted August 30, 2007 I could be wrong, since i personally hate regex, but shouldn't your pattern be: if (preg_match('/Average Rate[^0-9]*([0-9.]+)/i', $data, $regs)){ Noting the . rather than the , Quote Link to comment https://forums.phpfreaks.com/topic/67347-preg_match/#findComment-337896 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.