Jump to content

michael.davis

Members
  • Posts

    61
  • Joined

  • Last visited

Everything posted by michael.davis

  1. I guess what I am trying to ask is what is the code format to look at not only one word but two words like Cloudy and LGT RAIN in one field like it is below: ([a-z/]+)\s+ $expr = "%$city*?\s+ ([a-z/]+)\s+ (n/a|\d+)\s+ (n/a|\d+)\s+ (n/a|\d+)\s+ ([a-z0-9]+)\s+ (n/a|[0-9.]+[a-z])%ix";
  2. Happy Monday Everyone! I hope you all had a great weekend! I have a script that usually runs just fine, however, I ran into an issue today. We are having light rain, this my code below is not working due to the $match[1] field is not one word, it is two words. If I change the $city to a condition that is one word, then it works fine. I know it is something simple and hope someone can help me with it. <?php $data = file_get_contents('http://www.srh.noaa.gov/productview.php?pil=OHXRWROHX') or die("Can't open URL"); $city = 'Nashville'; $expr = "%$city*?\s+ ([a-z/]+)\s+ (n/a|\d+)\s+ (n/a|\d+)\s+ (n/a|\d+)\s+ ([a-z0-9]+)\s+ (n/a|[0-9.]+[a-z])%ix"; preg_match( $expr, $data, $match ); $site = $match[0]; $COND = $match[1]; $TEMP = $match[2]; $DEW = $match[3]; $HUMID = $match[4]; $WIND = $match[5]; $PRES = $match[6]; echo $site; echo $COND; echo $$TEMP; echo $DEW; echo $HUMID; echo $WIND; echo $PRES; echo $data; ?> The data below is what the script pulls in. The city of Gallatin works fine, but Nashville does not due to the two word in the $COND field. 562 ASUS44 KOHX 121310 RWROHX MIDDLE TENNESSEE HOURLY WEATHER ROUNDUP NATIONAL WEATHER SERVICE NASHVILLE TN 700 AM CST MON NOV 12 2012 NOTE: "FAIR" INDICATES FEW OR NO CLOUDS BELOW 12,000 FEET WITH NO SIGNIFICANT WEATHER AND/OR OBSTRUCTIONS TO VISIBILITY. * THESE REPORTS ARE NOT UNDER NWS QUALITY CONTROL AND MAY NOT REPORT WEATHER SUCH AS PRECIPITATION AND FOG. TNZ005>011-023>034-057-059-062>066-078-080-121400 ...NORTHERN MIDDLE TENNESSEE... CITY SKY/WX TMP DP RH WIND PRES REMARKS ANTIOCH* N/A 52 48 87 W5 N/A BAXTER* N/A 59 52 77 SE13 N/A BURNS* N/A N/A N/A N/A W3 N/A CAMDEN* N/A 50 50 100 W6 N/A CELINA* N/A 61 59 94 SW8 N/A CLARKSVILLE LGT RAIN 52 50 93 NW9 30.16R FOG COLUMBIA CLOUDY 55 55 100 NW8 30.15R CROSSVILLE CLOUDY 59 54 83 S12G22 30.21R GALLATIN CLOUDY 57 57 100 SW8 30.14R DICKSON CLOUDY 50 48 93 W7 30.16R DOVER* N/A 52 50 93 W1 N/A GOODLETTSVILLE N/A 59 52 77 CALM N/A HERMITAGE* N/A 57 55 94 MISG N/A KINGSTON SPGS* N/A 54 52 94 CALM N/A LAFAYETTE* N/A 57 57 100 SW7 N/A LEBANON CLOUDY 57 57 100 SW8 30.12R LIVINGSTON CLOUDY 58 54 86 S15 30.12S MOUNT JULIET* N/A N/A N/A N/A CALM N/A NASHVILLE LGT RAIN 57 55 94 SW8 30.14R FOG OLD HICKORY* N/A 59 59 100 W3 N/A PEGRAM* N/A N/A N/A N/A W3 N/A PORTLAND CLOUDY 55 55 100 SW13 30.12R SMYRNA LGT RAIN 57 57 100 SW5 30.16R FOG WAVERLY* N/A 52 48 87 W5 N/A WHITE BLUFF* N/A 54 50 87 MISG N/A $$ TNZ056-058-060-061-075>077-079-093>097-121400 ...SOUTHERN MIDDLE TENNESSEE... CITY SKY/WX TMP DP RH WIND PRES REMARKS ALTAMONT* N/A 57 55 94 S5 N/A BELLEVUE* N/A 55 54 94 CALM N/A CHAPEL HILL* N/A 57 55 94 SW2 N/A CULLEOKA* N/A 57 57 100 S3 N/A EAGLEVILLE* N/A N/A N/A N/A W3 N/A FAIRVIEW* N/A 52 52 100 W1 N/A FAYETTEVILLE CLOUDY 57 56 97 S10 30.15R LEWISBURG CLOUDY 57 55 94 S5 30.14R MANCHESTER* N/A 59 57 94 S6G20 N/A MCMINNVILLE MOCLDY 59 56 89 S12 30.14S MOUNT PLEASANT N/A 55 54 94 CALM N/A MURFREESBORO CLOUDY 59 58 96 SW5 30.13R SHELBYVILLE CLOUDY 57 55 94 S12 30.15 SHELBYVILLE* N/A 61 59 94 SW8 N/A SPRING HILL* N/A 59 55 88 NE5 N/A THOMPSON STN* N/A 57 55 94 W3 N/A TULLAHOMA MOCLDY 57 55 94 S13 30.16R WINCHESTER CLOUDY 59 55 88 SE6 30.15F $$ ...KEY TO REMARKS... VSB - VISIBILITY IN MILES WCI - WIND CHILL INDEX HX - HEAT INDEX Thanks! Mike
  3. Great Thanks!
  4. Hi Everyone! Getting this error code with my php script that I am using. Deprecated: Function ereg() is deprecated Was working fine and now it is not. <?php chdir(dirname(__FILE__)); $dir = "/sync/www/html/ohx/training"; $numberOfFiles = 6; $pattern = '\.(pdf|xlsx|xls|doc|docx)$'; $newstamp = 0; $newname = ""; $dc = opendir($dir); unset($fils); while ($fn = readdir($dc)) { # Eliminate current directory, parent directory if (ereg('^\.{1,2}$',$fn)) continue; # Eliminate other pages not in pattern if (! ereg($pattern,$fn)) continue; //echo "<a href='$fn'>$fn</a><br>\n"; $timedat = filemtime("$dir/$fn"); //$fils["a" . $timedat . "$fn"] = $fn;//keep file name and time so if 2 files have same time they dont get lost $fils[$fn] = $timedat;//keep file name and time so if 2 files have same time they dont get lost /*if ($timedat > $newstamp) { $newstamp = $timedat; $newname = $fn; } */ } ksort ($fils, SORT_NUMERIC); //for($i = 0; $i < $numberOfFiles ; $i++) $fils2 = array_keys($fils); $i = 0; foreach($fils2 as $s){ $i++; echo "<a href=training/$s>$s</a><br>\n"; //echo "$i " . $s . "<br>\n"; if($i == $numberOfFiles )break; } ?>
  5. Ok I just edited the code and can get the 24 hour data. <?php //$xml = new SimpleXML $xml = SimpleXML_load_file('http://www.amecim.com/metronashvillewater/metronashvilleraingaugeservice.asmx/getAllGaugesAllIntervals'); $firstChildrenArray = array(); // going to hold parent elements $secondChildArray = array(); // going to hold child elements of each clsRainGaugeReading foreach($xml->children() as $child) { $firstChildrenArray[] = $child->getName(); } foreach($firstChildrenArray as $v){ foreach($xml->{$v}->TwentyfourHour as $vv){ $secondChildArray[] = get_object_vars($vv); } } echo "<pre>"; // get rid of this line print_r($secondChildArray); // just to demonstrate end result echo "" . $secondChildArray[3]['GaugeName'] ; ?>
  6. http://www.amecim.com/metronashvillewater/metronashvilleraingaugeservice.asmx/getAllGaugesAllIntervals The file above has 15 min, 30 minute, 1 hour, 2 hour, 4 hour, 6 hour and 24 values in this file. The USGS prefers we source this to gather all intervals and data associated with that interval that we require. This is really nice as it will be a one sources, yet the php code that we are working on slightly changes. Could use some help. Thanks! Mike
  7. Hi Drongo_III! That is exactly what I needed. Thanks!!!!
  8. Thanks for your help Drongo_III! What I am trying to do is pull in the data and format it in a line format to be ingested into our database. What I would like to do is put the site and related data into one line at a time. Fore example: SITE DATE TIME VALUE BntCrk : 82712 DH1640/0 Does that make sense? Thanks! Mike
  9. So to break it out into two different arrays will work best? Make sense. Ok...brain dump here. I believe my brain is fried now. To list the matching first array item with the first array data fields, I need to add? Thanks for your help! Mike
  10. Interesting. I used the SimpleXMLElement in a previous script and works fine.
  11. Good Monday Everyone! I am working on some code to pull in an XML formatted page from the internet and break it out into variables. I am not sure what I am missing here, but it will not parse the data. I am sure something simple. Here is the web link: http://www.amecim.com/metronashvillewater/metronashvilleraingaugeservice.asmx/getAllGauges15m Listed below is the code: <?php // // 15 Minute Gauge Data // $xml = new SimpleXMLElement('http://www.amecim.com/metronashvillewater/metronashvilleraingaugeservice.asmx/getAllGauges15m', 0, true); foreach ($xml->clsRainGaugeReading as $row) { printf("Sample Date: %s\n", $row->SampleDate); echo "<br>"; printf("Sample Time: %s\n", $row->SampleTime); echo "<br>"; printf("Gauge Name: %u\n", $row->GaugeName); echo "<br>"; printf("Sample Value: %u\n", $row->SampleValue); echo "<br>"; echo "<br>"; } ?> Thanks in advance for any help. Mike
  12. Thank you for the help! I was trying my darnest to display just that one line, then to get explode to work. Thank you!
  13. This link is better for what I am doing: http://www.srh.noaa.gov/productview.php?pil=OHXRWRMEG
  14. Understand. Nashville is used once. The City name stays the same length but the data in the other columns besides the city name are not fixed . Using the explode function should work. Does the explode function only used fixed spaces or will explode adjust for the white spacing differences?
  15. Looking to the explode function. Thanks! Just not sure how to grab just that one line.
  16. Still digging on this. There is a line in the file that I am pulling in: NASHVILLE PTCLDY 62 58 86 CALM 30.13R I am trying to grab only this line... and break it up into segments and put into variables. I am able to preg match the NASHVILLE word, but not sure how to break up only this line and have each segment as a variable. Does that make sense? ?php $data = file_get_contents('http://www.srh.noaa.gov/productview.php?pil=OHXRWROHX'); echo $data; if ( preg_match("/NASHVILLE/", $data, $match) ) { echo "A match was found."; $site = $match[0]; $temp = $match[2]; echo "Site: " . $site; echo "Temp: " . $temp; } else { echo "A match was not found."; } ?>
  17. Happy Wednesday Everyone! Thank you in advance for helping me with this. I am grabbing a file from the internet, and trying to gather the line data associated with one location from it. I want to break out the individual parts of that line and put into a variable to use. Here is my code below: <?php $data = file_get_contents('http://www.srh.noaa.gov/productview.php?pil=OHXRWROHX'); echo $data; if ( preg_match("/NASHVILLE/", $data, $match) ) { echo "A match was found."; $site = $match[0]; $temp = $match[1]; echo "Site: " . $site; echo "Temp: " . $temp; echo "<br />"; } else { echo "A match was not found."; } ?> Thanks again for your help. Mike
  18. Awesome! Thank you for the help! I will change this and see how it goes!
  19. Once again, as I look at my error_logs, I see another page that has a few errors. [root@ohx-lw-tanager httpd]# tail -f error_log [Wed Jul 11 13:07:17 2012] [error] [client 205.165.229.243] PHP Notice: Undefined index: SPC in /sync/public/intranet/ohx/spc_feed.php on line 60, referer: http://www/ [Wed Jul 11 13:07:17 2012] [error] [client 205.165.229.243] PHP Notice: Undefined offset: 1 in /sync/public/intranet/ohx/spc_feed.php on line 66, referer: http://www/ [Wed Jul 11 13:07:17 2012] [error] [client 205.165.229.243] PHP Notice: Undefined index: SPC MD 1449\n in /sync/public/intranet/ohx/spc_feed.php on line 60, referer: http://www/ [Wed Jul 11 13:07:17 2012] [error] [client 205.165.229.243] PHP Notice: Undefined offset: 1 in /sync/public/intranet/ohx/spc_feed.php on line 66, referer: http://www/ [Wed Jul 11 13:07:17 2012] [error] [client 205.165.229.243] PHP Notice: Undefined index: SPC Jul 11, 2012 1730 UTC Day 2 Convective Outlook\n in /sync/public/intranet/ohx/spc_feed.php on line 60, referer: http://www/ [Wed Jul 11 13:07:17 2012] [error] [client 205.165.229.243] PHP Notice: Undefined offset: 1 in /sync/public/intranet/ohx/spc_feed.php on line 66, referer: http://www/ [Wed Jul 11 13:07:17 2012] [error] [client 205.165.229.243] PHP Notice: Undefined index: SPC Jul 11, 2012 1630 UTC Day 1 Convective Outlook\n in /sync/public/intranet/ohx/spc_feed.php on line 60, referer: http://www/ [Wed Jul 11 13:07:17 2012] [error] [client 205.165.229.243] PHP Notice: Undefined offset: 1 in /sync/public/intranet/ohx/spc_feed.php on line 66, referer: http://www/ [Wed Jul 11 13:07:17 2012] [error] [client 205.165.229.243] PHP Notice: Undefined index: SPC Day 1 Fire Weather Outlook\n in /sync/public/intranet/ohx/spc_feed.php on line 60, referer: http://www/ [Wed Jul 11 13:07:17 2012] [error] [client 205.165.229.243] PHP Notice: Undefined offset: 1 in /sync/public/intranet/ohx/spc_feed.php on line 66, referer: http://www/ I am not sure why this is acting this way. I have hightlighted the areas in the code that the error log is point to. This wasnt an issue before, but now is. Can anyone point out my issue? Thanks! Mike <?php # I'm including the open and close font tags so that undefined # types will be handled gracefully. Since "Freeze Warning" is # not defined, it's displayed in the default link color defined # by the user. Class tags would be better than <font color=#xxxxxx> # cuz then they would change color when selected. $color_table = array( "Tornado Watch" => "<b><font color=#FF0000>,</font></b>", "Severe Thunderstorm Watch" => "<b><font color=#FFA500>,</font></b>", "Flash Flood Warning" => "<b><font color=#8B0000>,</font></b>", ); $spcread_insideitem = false; $spcread_tag = ""; $spcread_title = ""; $spcread_description = ""; $spcread_link = ""; function spc_startElement($spcread_parser, $spcread_name, $spcread_attrs) { global $spcread_insideitem, $spcread_tag, $spcread_title, $spcread_description, $spcread_link; if ($spcread_insideitem) { $spcread_tag = $spcread_name; } elseif ($spcread_name == "ITEM") { $spcread_insideitem = true; } } function spc_endElement($spcread_parser, $spcread_name) { global $spcread_insideitem, $spcread_tag, $spcread_title, $spcread_description, $spcread_link, $color_table; if ($spcread_name == "ITEM") { $title = split(' *- *', $spcread_title); [b]$font = split(',', $color_table[$title[0]])[/b]; printf("<a target='_blank' href='%s'>%s%s%s</a><br>", trim($spcread_link), [b]$font[0],[/b] htmlspecialchars(trim($spcread_title)), [b]$font[1]);[/b] //printf("<span class='BodyText'>%s</span><br>", // htmlspecialchars(trim($spcread_description))); $spcread_title = ""; $spcread_description = ""; $spcread_link = ""; $spcread_insideitem = false; } } function spc_characterData($spcread_parser, $spcread_data) { global $spcread_insideitem, $spcread_tag, $spcread_title, $spcread_description, $spcread_link; if ($spcread_insideitem) { switch ($spcread_tag) { case "TITLE": $spcread_title .= $spcread_data; break; case "DESCRIPTION": $spcread_description .= $spcread_data; break; case "LINK": $spcread_link .= $spcread_data; break; } } } $spcread_xml_parser = xml_parser_create(); xml_set_element_handler($spcread_xml_parser, "spc_startElement", "spc_endElement"); xml_set_character_data_handler($spcread_xml_parser, "spc_characterData"); $spcread_fp = fopen("http://www.spc.noaa.gov/products/spcrss.xml","r") or die("Error reading RSS data."); while ($spcread_data = fread($spcread_fp, 4096)) { xml_parse($spcread_xml_parser, $spcread_data, feof($spcread_fp)) or die(sprintf("XML error: %s at line %d", xml_error_string(xml_get_error_code($spcread_xml_parser)), xml_get_current_line_number($spcread_xml_parser))); } fclose($spcread_fp); xml_parser_free($spcread_xml_parser); ?>
  20. Hi! I have written some code to strip the weather forecast of a text file and it is working just fine. In my error_log, I noticed the following errors: [Wed Jul 11 12:56:25 2012] [error] [client 205.165.229.208] PHP Notice: Undefined variable: state in /sync/public/intranet/ohx/tvwx/index.php on line 114 [Wed Jul 11 12:56:25 2012] [error] [client 205.165.229.208] PHP Notice: Undefined variable: state in /sync/public/intranet/ohx/tvwx/index.php on line 117 Line 114 refers to $state == 0; Line 117 refers to if ($state == 0) { I have this section in bold in my code. Can someone point me in the right direciton to correct this? Thanks! Mike My code is listed below: <?php function getHeadlines($product) { [b] $retarray = array(); $lines = split("\n", $product); $state == 0; foreach ($lines as $line) { if ($state == 0) { if (substr($line,0,3) == "...") { $headline = $line . "\n"; $state = 1;[/b] } } else if ($state == 1) { if (preg_match("/^\s*$/", $line)) { $headlines .= $headline . "\n"; $retarray[] = $headlines; $headlines=""; $state = 0; } else { $headline .= $line; } } } return $retarray; } function expandUGC($str) { $str = ereg_replace("/[\r\n]/", "", $str); $codes = split("-", $str); foreach ($codes as $code) { if (preg_match("/^([A-Z]{2}([CZ]))/", $code, $m)) { $loc = $m[0]; $typ = $m[2]; } if (preg_match("/^\d{6}[A-Z]?$/", $code)) { $tm = $code; break; } else if (preg_match("/(\d\d\d)>(\d\d\d)\s*$/", $code, $m)) { for ($i = $m[1]; $i <= $m[2]; $i++) { if ($typ == "C" && !($i % 2)) { // bypass even numbers for FIPS codes } else { $retarray[] = sprintf ("%s%03d", $loc, $i); } } } else if (preg_match ("/(\d{3})$/", $code, $m)) { $retarray[] = $loc . $m[0]; } else { // probably an error break; } } return join("-", $retarray) . "-" . $tm . "-"; } function getSegments($str) { $retarray = array(); $text = strtok ($str, "\$\$"); while ($text) { if (preg_match("/^.*\n([A-Z]{2}[CZ]\d\d\d.*)$/sm", $text, $seg)) { $text = $seg[1]; } if (preg_match("/^[A-Z]/", $text)) { $retarray[] = $text; } $text = strtok("\$\$"); } return $retarray; } function getSegmentsByUGC($product, $code) { $retarray = array(); $segments = getSegments($product); foreach ($segments as $segment) { $ugc = expandUGC($segment); if (preg_match ("/$code/i", $ugc)) { $retarray[] = $segment; } } return $retarray; } // function that returns x periods in an array... function getPeriods($product, $num) { $retarray = array(); $lines = split("\n", $product); $state = 0; $count = 0; foreach ($lines as $line) { if ($state == 0) { if (preg_match ("/^\.[A-Z].*\.\.\./", $line)) { $period = "$line\n"; $state = 1; } } else if ($state == 1) { if (preg_match("/^\.[A-Z].*\.\.\./", $line)) { $retarray[] = "$period\n"; $count++; $period = "$line\n"; } else { $period .= "$line\n"; } } if ($count >= $num) { break; } } return $retarray; } $file_array = file("ZFPOHX"); $prod=join("", $file_array); $segments = getSegmentsByUGC($prod, "TNZ027"); $headlines=getHeadlines($segments[0]); //print "" . join("<BR>", $headlines) . "\n"; $periods_one_and_two = getPeriods($segments[0], 1); print "" . join(" ", $periods_one_and_two) . " "; ?>
  21. Awesome! Thank you, Requinix! You Rock!
  22. Hi! I am extracting the current lake level of my nearby lake and with the code listed below, I am only displaying the very first lake level from 11AM. I am in need of the last lake level from 6PM. Can someone point me in the right direction. Listed below is my code: <?php //old Hickory $summerpool = 445.00; $data = file_get_contents('http://www.tva.gov/lakes/xml/OHH_R.xml'); $regex = '@<UPSTREAM_ELEV>.*?</UPSTREAM_ELEV>@'; preg_match($regex, $data, $match); $elev = substr(substr($match[0], 15), 0, -16); if ($elev == $summerpool) echo "Level: $elev"; $average = $summerpool - $match[1]; if ($elev > $summerpool) echo "Level: $elev"; $average = $summerpool - $match[1]; if ($elev < $summerpool) echo "Level: $elev"; $average = $elev - $summerpool; ?> The XML from which I grab the data: <DBI driver="rvsp"> <RESULTSET> <ROW> <MSG_TXT> Old Hickory will be spilling, without generation, until further notice. </MSG_TXT> </ROW> </RESULTSET> <RESULTSET> <ROW> <OBS_DAY>6/22/2012</OBS_DAY> <OBS_HR>11 am</OBS_HR> <UPSTREAM_ELEV>444.96</UPSTREAM_ELEV> <DOWNSTREAM_ELEV>386.06</DOWNSTREAM_ELEV> <AVG_HOURLY_DISCHARGE>4,300</AVG_HOURLY_DISCHARGE> </ROW> <ROW> <OBS_DAY>6/22/2012</OBS_DAY> <OBS_HR>12 pm</OBS_HR> <UPSTREAM_ELEV>444.91</UPSTREAM_ELEV> <DOWNSTREAM_ELEV>385.91</DOWNSTREAM_ELEV> <AVG_HOURLY_DISCHARGE>4,300</AVG_HOURLY_DISCHARGE> </ROW> <ROW> <OBS_DAY>6/22/2012</OBS_DAY> <OBS_HR>1 pm</OBS_HR> <UPSTREAM_ELEV>444.85</UPSTREAM_ELEV> <DOWNSTREAM_ELEV>385.85</DOWNSTREAM_ELEV> <AVG_HOURLY_DISCHARGE>4,300</AVG_HOURLY_DISCHARGE> </ROW> <ROW> <OBS_DAY>6/22/2012</OBS_DAY> <OBS_HR>2 pm</OBS_HR> <UPSTREAM_ELEV>444.91</UPSTREAM_ELEV> <DOWNSTREAM_ELEV>385.91</DOWNSTREAM_ELEV> <AVG_HOURLY_DISCHARGE>4,300</AVG_HOURLY_DISCHARGE> </ROW> <ROW> <OBS_DAY>6/22/2012</OBS_DAY> <OBS_HR>3 pm</OBS_HR> <UPSTREAM_ELEV>444.95</UPSTREAM_ELEV> <DOWNSTREAM_ELEV>386.05</DOWNSTREAM_ELEV> <AVG_HOURLY_DISCHARGE>4,300</AVG_HOURLY_DISCHARGE> </ROW> <ROW> <OBS_DAY>6/22/2012</OBS_DAY> <OBS_HR>4 pm</OBS_HR> <UPSTREAM_ELEV>444.97</UPSTREAM_ELEV> <DOWNSTREAM_ELEV>385.87</DOWNSTREAM_ELEV> <AVG_HOURLY_DISCHARGE>4,300</AVG_HOURLY_DISCHARGE> </ROW> <ROW> <OBS_DAY>6/22/2012</OBS_DAY> <OBS_HR>5 pm</OBS_HR> <UPSTREAM_ELEV>444.93</UPSTREAM_ELEV> <DOWNSTREAM_ELEV>385.83</DOWNSTREAM_ELEV> <AVG_HOURLY_DISCHARGE>4,300</AVG_HOURLY_DISCHARGE> </ROW> <ROW> <OBS_DAY>6/22/2012</OBS_DAY> <OBS_HR>6 pm</OBS_HR> <UPSTREAM_ELEV>444.95</UPSTREAM_ELEV> <DOWNSTREAM_ELEV>385.85</DOWNSTREAM_ELEV> <AVG_HOURLY_DISCHARGE>4,300</AVG_HOURLY_DISCHARGE> </ROW> </RESULTSET> </DBI> Thanks! Mike
  23. Ah... awesome! Thank you for the help! Mike
  24. Ah.... ok that makes sense. Use the file() command rather than the file_get_contents. I am only wanting to pull certain segments of this file. That is why I was looking to use the variable to work with this. Thanks! Mike
  25. Hi All! I am trying to read line for line from a file that is on a weather site. I can read the file from the internet, but do not want nor need to write the file on the server to source it. Feel it would be duplication. Can someone take a quick look at my code and see what I am missing? <?php //MTR $lines = file_get_contents('http://www.srh.noaa.gov/rtimages/ohx/current_wx/MTRBNA'); $i=1; foreach($lines as $line ){ $var["line" . $i] = $line; $i++; } extract($var); echo $line1; echo $line2; echo $line3; echo $line4; echo $line5; echo $line6; ?>
×
×
  • 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.