Show the METAR of location airport

Hey! This code snippet shows the METAR of the current location airport of the pilot.

You can put it anywhere (I use it on my frontpage_main)

 

\<?php $last\_location = PIREPData::getLastReports(Auth::$userinfo-\>pilotid, 1, PIREP\_ACCEPTED); if(!$last\_location) { echo ''; } else { ?\> \<br\>\<br\>Your current airport METAR: \<i\>\<?php echo file\_get\_contents("http://wx.ivao.aero/metar.php?id=$last\_location-\>arricao"); ?\>\</i\> \<?php } ?\>

This code snippet uses the IVAO-METAR. 

I would suggest changing the code as the above to make it more portable:

<?php $last_location = PIREPData::getLastReports(Auth::$userinfo->pilotid, 1, PIREP_ACCEPTED);
$icao = $last_location->arricao;
	if(!$last_location) {
		echo '';
	} else { ?>
		<br><br>Your current airport METAR: <i><?php echo file_get_contents("http://wx.ivao.aero/metar.php?id=$icao"); ?></i>
	<?php
	} ?>

This allows you to change ICAO variable to anything you want such as $schedule->depicao or $schedule->arricao or anything else so you can have data from other locations too.

1 Like