I have a multidimensional array.
$parent_array($child1('lat','long'),$child2('lat','long')...)
The amount of child arrays can be of any value per request starting from 2. The parent array is then called into a function that has a google distance calculator between to or more points.
function distance($parent_array)
{
foreach ( $parent_array as $child){
$distance = file_get_contents('https://maps.googleapis.com/maps/api/distancematrix/json?units=metric&origins='.$child1['lat'].','.$child1['long'].'&destinations='.$child2['lat'].','.$child2['long'].'&key=********************************');
$trim = trim($this->objectToArray($distance)['rows'][0]['elements'][0]['distance']['text'],' km');
}
return $trim;
}
I need to get this function to calculate the distance between all posted child arrays as illustrated on the above function using
$child1 and $child2