sphinx Posted December 12, 2010 Share Posted December 12, 2010 Hello, I'm looking to preg_match multiple statistics from a page. The first one works perfectly, but I need to grab and display three different types of data and display on one page. Can this be done? Thanks <?php $page_contents = file_get_contents("http://www.site.com"); $matches = array(); preg_match('/([0-9]+) day, ([0-9]+) hours, ([0-9]+) min, ([0-9]+) sec/', $page_contents, $matches); echo $matches[0]; ?> Link to comment https://forums.phpfreaks.com/topic/221429-multiple-preg_match/ Share on other sites More sharing options...
Zurev Posted December 13, 2010 Share Posted December 13, 2010 Can you not do a seperate preg_match for each statistic? (Recommending preg_match_all) and then if need be just use array merge? Link to comment https://forums.phpfreaks.com/topic/221429-multiple-preg_match/#findComment-1146474 Share on other sites More sharing options...
requinix Posted December 13, 2010 Share Posted December 13, 2010 Depending on how you want the final array, array_merge might not even be necessary - just pass in the right PREG_*_ORDER flag. Link to comment https://forums.phpfreaks.com/topic/221429-multiple-preg_match/#findComment-1146483 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.