There is probably a much better way to do this, right?
$obj->decode_metar() is very fast, so I wanted to "flatten" it into a list
of variables I could do with what I pleased, like:
echo "Station = $var_station<br>";
echo "Temperature = $var_temperature_temp_f<br>";
echo "Wind Direction = $var_wind_deg<br>";
echo "Wind Strength = $var_wind_miles_per_hour<br>";
blah, blah, blah
or in table or shockwave animation or XML type format or anything.
The code snipplet below works fine in assigning all the variables, but
there is probably a much better way to do this, right? Does this make any
more sense than creating a "pretty_print" object to display the data?
Thanks!
[please note that I am discussing the latest 1.9.4 beta code]
-fred
$myarray = $obj->decode_metar();
while (list($key,$val)=each($myarray)) {
if ($key == "station") {
$var_station = $val;
}
if ($key == "rel_humidity") {
$var_rel_humidity = $val;
}
if ($key == "temperature") {
$temperature = $val;
while (list($key,$val)=each($temperature)) {
if ($key == "temp_c") {
$var_temperature_temp_c = $val;
}
if ($key == "temp_f") {
$var_temperature_temp_f = $val;
}
if ($key == "dew_c") {
$var_temperature_dew_c = $val;
}
if ($key == "dew_f") {
$var_temperature_dew_f = $val;
}
}
}
if ($key == "wind") {
$windarray = $val;
while (list($key,$val)=each($windarray)) {
if ($key == "deg") {
$var_wind_deg = $val;
}
if ($key == "knots") {
$var_wind_knots = $val;
}
if ($key == "meters_per_second") {
$var_wind_meters_per_second = $val;
}
if ($key == "miles_per_hour") {
$var_wind_miles_per_hour = $val;
}
}
}
}