Used this to convert gpx files from my Android Move! Bike Computer app to kml files (which the app will also do if the track is still on your phone)
To create a string for the kml coordinates tag from gpx file contents (using PHPGPX to read the file, and assuming only one track with one segment in the file):
$gpx = new GPX();
$gpx->XMLin(base_url() . 'routes/millenium_trail.gpx');
foreach ($gpx->tracks[0]->segments[0]->trkpts as $trkpt) {
echo $trkpt->longitude . ',' . $trkpt->latitude . ',' . trim($trkpt->elevation) . ' ';
}
