我正在使用Google Place API查找地址。 一些输出的例子:将地址字符串(Google Places API)分段并添加到数组中
Laag-Beugt 2 C, 5473 KB Heeswijk Dinther, Nederland
Industrieweg 36, 8091 AZ Wezep, Nederland
Rijakkerweg 7, 5741 RR Beek en Donk, Nederland
Antoon van Hooffplein 1, 6816 SH Arnhem, Nederland
Lingewal 2A, 6681 LJ Bemmel, Nederland
Lekdijk 120, 3999 NX Tull en Het Waal, Nederland
Concordialaan 2, 4874 NZ Etten-Leur, Nederland
Tibsterwei 4B, 9131 EG Ee, Nederland
Besser Str. 45, 34281 Gudensberg, Duitsland
Fabriekstraat 2, 9470 Denderleeuw, België
现在我想这些字符串切成片,放在阵列,如:
Array
(
[adres] => Laag-Beugt 2C //No space between the 2 and the C
[postcode] => 5473 KB
[plaats] => Heeswijk Dinther
[land] => Nederland
)
Array
(
[adres] => Lekdijk 120
[postcode] => 3999 NX
[plaats] => Tull en Het Waal
[land] => Nederland
)
Array
(
[adres] => Tibsterwei 4B
[postcode] => 9131 EG
[plaats] => Ee //Shortest cityname in the Netherlands
[land] => Nederland
)
Array
(
[adres] => Besser Str. 45
[postcode] => 34281
[plaats] => Gudensberg
[land] => Duitsland
)
Array
(
[adres] => Fabriekstraat 2
[postcode] => 9470
[plaats] => Denderleeuw
[land] => België
)
由于还有的“邮政编码”(邮编)之间没有逗号和“ plaats'(城市),我不能使用explode
。输出将是这样的:
Array
(
[adres] => Laag-Beugt 2C
[postcode] => 5473 KB Heeswijk Dinther
[plaats] => Nederland
)
在荷兰一个邮政编码的格式如下1234 AA
,所以我可以使用正则表达式来打一个逗号连续两个京后,但在比利时的邮编是1234
格式和德国12345
。所以我有点卡在这里..
有人可以帮助吗?
你到目前为止试过了什么?张贴你的企图.. –
@Uchida我已经更新了我的问题。 – JK87