Jump to content

[SOLVED] simple preg_match_all issue


pkSML

Recommended Posts

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!

Link to comment
https://forums.phpfreaks.com/topic/113964-solved-simple-preg_match_all-issue/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.