Interesting, thanks for the response! I had no idea what was going in to the calculations.
I don't know what formula went into it, but the FAA has an Excel calculator to do basically what you want at http://www.faa.gov/about/office_org/hea ... rps_tools/
use the "Ellipsoidal Calculator Spreadsheet".
The "Three Points" tab would return the desired values: A = the origin airport, B = destination, C = your airport, and it will return "y" which is the distance to courseline. This is one of the calculators used to assist in instrument approach procedure design, so it should be accurate.
Unfortunately, the spreadsheet is password-protected. Maybe the contact information at their main page, http://www.faa.gov/about/office_org/hea ... 00/afs420/
will help get you the formula that goes into it.
I know nothing about php or even if it's implementable from this Excel formula, but figured I'd offer that suggestion.