pkSML Posted July 9, 2008 Share Posted July 9, 2008 I'm trying to get this regex to work, but wind up banging my head on the wall instead... I'm grabbing the NOAA zone forecasts for Ohio (from http://www.weather.gov/view/prodsByState.php?state=oh&prodtype=zone ) You can see from the source code of that page that all the forecasts from a certain time are in < pre>< /pre> tags. The next oldest forecast is in another < pre>< /pre> tag set. I want to grab each forecast as an item in an array. Here's my code: <?php preg_match_all('@<pre>(.*)</pre>@s', $source, $results); print_r($source); ?> Unfortunately, I'm getting everything from the first opening PRE tag to the last closing PRE tag. Preg_match_all is greedy by default, isn't it? Thanks for any help/explanation! Quote Link to comment https://forums.phpfreaks.com/topic/113964-solved-simple-preg_match_all-issue/ Share on other sites More sharing options...
pkSML Posted July 9, 2008 Author Share Posted July 9, 2008 Silly me... It was greedy, and the U modifier turns that off. Quote Link to comment https://forums.phpfreaks.com/topic/113964-solved-simple-preg_match_all-issue/#findComment-585701 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.