Jump to content

Recommended Posts

Hi all. I decided it was time to re do my warning map that I have on my website as it was a very in-efficient way to create the map. I have been trying a few things to determine the quickest and most efficient way to do this however I would like your opinion/help.  I have a special weather statements text file seen here http://feeds.michiganwxsystem.com/EC/CWTO/WOCN11.txt . What I am trying to do is match the locations from an array to that text file to see if a special weather statement is in effect for a given region. I am using a preg_match statement currently however I believe it would be easier if I could have an array with every forecast location in it and have the preg_match statement loop through each location in the array to see if there is a special weather statement in effect. The code I have so far is shown below it works from what I can see, the preg_match is looping through the area and is returning if a special weather statement is in effect. It will echo Special Weather Statement however I have to know which location it is returning that value for. If anyone can point me in the right direction from here that would be greatly appreciated.

 

Thanks, Dave

 

<?php


$sws = @file_get_contents('http://feeds.michiganwxsystem.com/EC/CWTO/WOCN11.txt');


$array = array(
    "CITY OF HAMILTON",
    "WINDSOR - ESSEX - CHATHAM-KENT",
"WINDSOR - LEAMINGTON - ESSEX COUNTY",
"CHATHAM-KENT - RONDEAU PARK",
    "SARNIA - LAMBTON",
"WATFORD - PINERY PARK - EASTERN LAMBTON COUNTY",
"SARNIA - PETROLIA - WESTERN LAMBTON COUNTY");

foreach ($array as $location) {

$warning = preg_match('/[\s\w\-]?SPECIAL WEATHER STATEMENT FOR:[\s\w\-\=NEW=]+('.$location.')/', $sws , $matches );

if(!($matches == NULL))
{
echo "Special Weather Statement";
}


}



?>

Edited by davefootball123
Link to comment
https://forums.phpfreaks.com/topic/275480-need-help-with-array/
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.