Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.