I'm trying to echo the first lat&lng coords of a GPX file but they are getting in revers order; last first... I've tried with array_reverse but I'm not being able.
Here the code:
<trkseg>
<trkpt lat="43.338377" lon="-3.009481">
<ele>11.0</ele>
<time>2016-07-12T16:49:56Z</time>
</trkpt>
<trkpt lat="43.338117" lon="-3.009256">
<ele>13.0</ele>
<time>2016-07-12T16:50:16Z</time>
</trkpt>
<trkpt lat="43.338068" lon="-3.009227">
<ele>13.0</ele>
<time>2016-07-12T16:50:36Z</time>
</trkpt>
<trkpt lat="43.337982" lon="-3.009417">
<ele>11.0</ele>
<time>2016-07-12T16:50:56Z</time>
</trkpt>
<trkpt lat="43.337897" lon="-3.009664">
<ele>8.0</ele>
<time>2016-07-12T16:51:16Z</time>
</trkpt>
</trkseg>
$xml = new SimpleXMLElement($contents);
foreach($xml->trk->trkseg->trkpt as $point){}
echo $point[lat];
echo ", ";
echo $point[lon];
This will echo last coords pair:43.337897, -3.009664
How can I echo first pair??
Thanks in advance!!