Skip to content

Commit

Permalink
o Fixed Bug #14732 Parsing weird TAFs _again_ (reported by Robin King)
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.php.net/repository/pear/packages/Services_Weather/trunk@290193 c90b9560-bf6c-de11-be94-00142212c4b1
  • Loading branch information
Alexander Wirtz committed Nov 3, 2009
1 parent 311fb65 commit 1d2d115
Showing 1 changed file with 16 additions and 8 deletions.
24 changes: 16 additions & 8 deletions Weather/Metar.php
Expand Up @@ -559,13 +559,17 @@ function _parseWeatherData($data)
echo $data[$i]."\n";
}
}
// Eliminate trailing information
for ($i = 0; $i < sizeof($data); $i++) {
if (strpos($data[$i], "=") !== false) {
$data[$i] = substr($data[$i], 0, strpos($data[$i], "="));
$data = array_slice($data, 0, $i + 1);
break;
}
}
// Start with parsing the first line for the last update
$weatherData = array();
$weatherData["station"] = "";
// Eliminate trailing information
if (strpos($data, "=") !== false) {
$data = substr($data, 0, strpos($data, "="));
}
$weatherData["dataRaw"] = implode(" ", $data);
$weatherData["update"] = strtotime(trim($data[0])." GMT");
$weatherData["updateRaw"] = trim($data[0]);
Expand Down Expand Up @@ -1055,13 +1059,17 @@ function _parseForecastData($data)
echo $data[$i]."\n";
}
}
// Eliminate trailing information
for ($i = 0; $i < sizeof($data); $i++) {
if (strpos($data[$i], "=") !== false) {
$data[$i] = substr($data[$i], 0, strpos($data[$i], "="));
$data = array_slice($data, 0, $i + 1);
break;
}
}
// Ok, we have correct data, start with parsing the first line for the last update
$forecastData = array();
$forecastData["station"] = "";
// Eliminate trailing information
if (strpos($data, "=") !== false) {
$data = substr($data, 0, strpos($data, "="));
}
$forecastData["dataRaw"] = implode(" ", $data);
$forecastData["update"] = strtotime(trim($data[0])." GMT");
$forecastData["updateRaw"] = trim($data[0]);
Expand Down

0 comments on commit 1d2d115

Please sign in to comment.