将Geo位置ISO 6709解析为双数组

时间:2017-02-21 05:01:38

标签: php regex geolocation

如何使用php将格式±DD.DDDD±DDD.DDDD解析为Geolocation ISO 6709为double [lat,long]?

的示例:

'+18.81983-19.91984'将为Array ( [0] => +18.81983 [1] => -19.91984 ) )

'-8.8194+29.81982'将为Array ( [0] => -8.8194 [1] => +29.81982 ) )

'+29.1989+54.01983'将为Array ( [0] => +29.1989 [1] => +54.01983) )

1 个答案:

答案 0 :(得分:0)

试试这个:

preg_match_all('/(\+|\-)(\d+\.?\d+)/', '+18.81983-19.91984', $matches);
echo  $matches[0];

让我知道这对你有用。