for ($aircraft_id){ $current_point_x = $latitude $current_point_y = $longitude $waypoint_x = $latitude_next $waypoint_y = $longitude_next //do some calculations on calculate headings ! //output headings }