【发布时间】:2018-10-17 06:49:42
【问题描述】:
我尝试使用 PHP 从 Google KML 文件中收集坐标(经度和纬度)。
<Point>
<coordinates>45.51088930166307,52.52216552154544</coordinates>
</Point>
我可以用逗号分解坐标并得到如下结果:
[0] => 45.51088930166307
[1] => 52.52216552154544
为了得到这个结果,我正在使用:
explode(',', $coordinates);
如何用逗号分解坐标?
<Point>
<coordinates>45.51088930166307,51,52.52216552154544,75</coordinates>
</Point>
我需要的结果:
[0] => 45.51088930166307,51
[1] => 52.52216552154544,75
以及如何删除逗号后的数字?
[0] => 45.51088930166307
[1] => 52.52216552154544
谢谢,
【问题讨论】:
-
获取长度/2,然后剪掉
-
如果第一个逗号后面的数字长度不同,@VasylZhuryk 将不起作用。例如
x.xx,99,x.xx,100 -
为什么要投反对票?问题重复了吗?
-
感谢 Vasyl Zhuryk 和 Andreas 的回复!
标签: php regex kml google-earth kmz