Hello All,
Admittedly, I'm a total php noob! I wrote this script to pull the NOAA METAR & TAF information for an airport, run them through a little formatting and display them. The problem is the page is taking about 8 - 10 seconds to load!!
Here is my code - any suggestions are MUCH appreciated!
Thanks in Advance,
--Keith
<?php
@ $pointer = fopen("ftp://weather.noaa.gov/data/observations/metar/stations/KLU$
if ($pointer) {
$today = date("Y/m/d");
while (!feof($pointer)) {
$NOAA_METAR = fgets($pointer, 4096);
if (strpos($NOAA_METAR, $today) === !FASLE) {
$NOAA_METAR = substr($NOAA_METAR, 0, strpos($NOAA_METAR, 'AO2'));
$METAR = $METAR . $NOAA_METAR;
}
}
fclose($pointer);
echo "<b>METAR:</b> $METAR";
}
@ $pointer = fopen("ftp://weather.noaa.gov/data/forecasts/taf/stations/KLUK.TXT$
if ($pointer) {
$ctr = 1;
while (!feof($pointer)) {
$NOAA_TAF = fgets($pointer, 4096);
if (strpos($NOAA_TAF, $today) === !FASLE) {
$NOAA_TAF = str_replace(" ", " ", $NOAA_TAF);
if ($ctr != 1) {
$TAF = $TAF . " " . $NOAA_TAF . "<br>";
} else {
$TAF = $TAF . $NOAA_TAF . "<br>";
}
$ctr++;
}
}
fclose($pointer);
echo "<br><b>TAF:</b> $TAF";
}
?>