function populate_data($ICAO_arr) { global $Airports; for ($i = 0; $i < count($ICAO_arr); $i++) { $ICAO = $ICAO_arr[$i]; $metar_data = get_metar($ICAO); $taf_data = get_taf($ICAO); $Airports[] = array('ICAO' => $ICAO, 'METAR' => $metar_data, 'TAF' => $taf_data); } }
function metar_taf() { ?> <br/> <h4 style="font-weight:bold;">METAR/TAF GENERATOR</h4> <p>Insert up to 3 valid ICAO identifiers to get METAR and TAF Reports</p> <form action="<?php the_permalink(); ?> " id="avwx" method="POST"> ICAO CODES <input type="text" name="icao1" id="airport" maxlength="4" size="4" onkeyup="javascript:this.value=this.value.toUpperCase()"> <input type="text" name="icao2" id="airport" maxlength="4" size="4" onkeyup="javascript:this.value=this.value.toUpperCase()"> <input type="text" name="icao3" id="airport" maxlength="4" size="4" onkeyup="javascript:this.value=this.value.toUpperCase()"> <input type="submit" name="submit" id="submitted" value="GET REPORT"> </form> <br/> <?php if (isset($_POST['submit'])) { foreach ($_POST as $icao) { if ($icao == "GET REPORT") { break; } else { if ($icao != NULL) { echo get_metar($icao); echo "<br>"; echo "<br>"; echo get_taf($icao); echo "<br>"; echo "<br>"; } else { continue; } } } } }
<?php $ICAO = strval($_GET['ICAO'] ? $_GET['ICAO'] : '0'); $taf_data = getTAFdata(); echo get_taf($ICAO); function get_taf($ICAO) { global $taf_data; return $taf_data[$ICAO]; } function getTAFdata() { $query_str = 'http://www.ogimet.com/ultimos_tafs.php?lang=en&estado=Isra&fmt=txt&iord=yes&Send=Send'; $raw_data = file_get_contents($query_str); $taf_data = TAF_split($raw_data); return $taf_data; } function TAF_split($data) { $temp = explode("##########################################################", $data); $timeOfQuery = $temp[1]; $temp = explode('###################################', $temp[2]); $timeOfData = $temp[1]; $raw_data = $temp[2]; $temp = explode("TAF", $raw_data); $i = 1; while ($i < sizeof($temp)) { $tmp = explode('=', $temp[$i]); $key_str = trim(substr($tmp[0], 1, 5)); $tmp[0] = str_replace("BECMG", "<br/> " . PHP_EOL . "BECMG", $tmp[0]); $tmp[0] = str_replace("TEMPO", "<br/> " . PHP_EOL . "TEMPO", $tmp[0]);