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 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; 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 , Link to comment https://forums.phpfreaks.com/topic/67347-preg_match/#findComment-337896 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.