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]; ?> Quote Link to comment 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? Quote Link to comment 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. Quote Link to comment 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.