PEAR is archived and read-only

This mirror preserves historical PEAR package releases and metadata so existing references remain available.

Home » Web Services » Services_Weather » Bug #7928

Problems parsing array in Weather/Metar.php

Details

Submitted2006-06-16 17:49 UTC
Frommike at fullduplex dot org
StatusBogus
PackageServices_Weather
PHP Version5.1.2
OSDebian 2.6.15-1-486
Roadmaps(Not assigned)

Comments

[2006-06-16 17:49 UTC] mike at fullduplex dot org

Description:
------------
Metar.php dies while parsing some array. See Actual result.

I'm using the debian php5 package, if it makes any difference.

Test script:
---------------
<?php
include('Services/Weather.php');

$metar = &Services_Weather::service("METAR", array("debug" => 0)); if (Services_Weather::isError($metar)) {
die("Error: ".$metar->getMessage()."\n"); }

$location = "EGLL";
$url = "ftp://weather.noaa.gov/data/observations/metar/stations/" . $location . ".TXT";
$data = $metar->_parseWeatherData($url);
print_r($data);
?>

Expected result:
----------------
Multidimensional array with weather info.

Actual result:
--------------
Warning: implode() [function.implode]: Bad arguments. in /usr/share/php/Services/Weather/Metar.php on line 537

Warning: array_shift() [function.array-shift]: The argument should be an array in /usr/share/php/Services/Weather/Metar.php on line 541

Warning: implode() [function.implode]: Bad arguments. in /usr/share/php/Services/Weather/Metar.php on line 542
Array ( [station] => [dataRaw] => [update] => 1150469043 [updateRaw] => f )

[2006-08-06 14:38 UTC] eru at php dot net

Sorry, but your problem does not imply a bug in PEAR itself. For a
list of more appropriate places to ask for help using PEAR, please
visit http://pear.php.net/support/ as this bug system is not the
appropriate forum for asking support questions.

Thank you for your interest in PEAR.

Apparently you've read the how-to on builder.com which used the code in a way it's not supposed to be used. _parseWeatherData is not a function that a developer should access, because it's marked as a private function and thus is apt to change every once in a while. And that's precisely what happened: I've changed the function and it no longer expects a string but an array.

The solution for this is easy:
$data = $metar->getWeather("EGLL");

Please look at the example files on how to properly access the weather functions.

Btw. sorry for the late answer.

[2006-09-23 19:18 UTC] mouad dot evil at gmail dot com

moi aussi j'ai la maime ereur