title: PHP and GPS Coordinates, getting the total distance along paths made up of several points
body: <p>I just can't seem to figure out how to make efficient and clean looking code for figuring this out. </p>
  
  <p>I have a string of coordinates, each point is made up of Longitude, Latitude and Altitude naturally (I am not worried about altitude at all right now and I know the function I have for figuring out the footage does not support altitude):</p>
  
  <pre><code>$coordinates = "-82.36554110283872,26.15200821551467,0 -82.420692,26.097404,0 -82.52855700000001,26.186567,0 -82.41250599999999,25.996422,0 -82.50644510379755,26.05431354409091,0" 
  </code></pre>
  
  <p>I need to find out the distance in feet between each coordinate and add up the total.
  I have the following function(which works beautifully) to figure out the distance between two points:</p>
  
  <pre><code>function coordDistance($lat1, $lon1, $lat2, $lon2) {
  $delta_lat = $lat2 - $lat1;
  $delta_lon = $lon2 - $lon1;
  
  $earth_radius = 20908800.00; //Distance around the earth in feet
  
  $alpha  = $delta_lat/2;
  $beta   = $delta_lon/2;
  $a          = sin(deg2rad($alpha)) * sin(deg2rad($alpha)) + cos(deg2rad($lat1)) *    cos(deg2rad($lat2)) * sin(deg2rad($beta)) * sin(deg2rad($beta)) ;
  $c      = asin(min(1, sqrt($a)));
  $distance = 2*$earth_radius * $c;
  $distance = round($distance, 4);
  
  return $distance;
  }
  </code></pre>
  
  <p>The way I am currently breaking down my coordinates string and attempting to pass it to the function is completely ludicrous. Any suggestions on how to split the coordinates and break them down to get the total footage for the path in a nice way?</p>