<?php
function aerodromes_secours(&$aerodromes) {
  for ($i = 0; $i < sizeof($aerodromes)-1; $i++) {
	$j = 0;
	$secours = array();
	$result = pg_query_ok("select aerodromes_proches(1.05, '".$aerodromes[$i][position]."','".$aerodromes[$i+1][position]."') as id");
	while($line = @pg_fetch_array($result,$j++ )) {
	  $secours[] = array(id => $line[id],
	  					 position => pg_result($r = pg_query_ok("select nom, position from aerodromes where id = $line[id]"),0,"position"),
						 nom => pg_result($r, 0, "nom"));
	}
	$aerodromes[$i][secours] = $secours;		 
  }
}
?>