我正在尝试回复GPX文件的第一个lat& lng coords,但它们正在按顺序进行;最后一个......我尝试过使用array_reverse,但我无法做到。
这里是代码:
<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];
这将回显最后一对坐标:43.337897, -3.009664
我怎样才能回应第一对?
提前致谢!!