下面是從我想要抓住僅座標,並將它們存儲在所述一個維陣列的陣列的結果。PHP多維數組搜索鍵和顯示值
Array
(
[name] => jackson
[Status] => Array
(
[code] => 200
[request] => geocode
)
[Placemark] => Array
(
[0] => Array
(
[@attributes] => Array
(
[id] => p1
)
[address] => Jackson, MS, USA
[AddressDetails] => Array
(
[@attributes] => Array
(
[Accuracy] => 4
)
[Country] => Array
(
[CountryNameCode] => US
[CountryName] => USA
[AdministrativeArea] => Array
(
[AdministrativeAreaName] => MS
[SubAdministrativeArea] => Array
(
[SubAdministrativeAreaName] => Hinds
[Locality] => Array
(
[LocalityName] => Jackson
)
)
)
)
)
[ExtendedData] => Array
(
[LatLonBox] => Array
(
[@attributes] => Array
(
[north] => 32.3741783
[south] => 32.2232735
[east] => -90.0567509
[west] => -90.3128697
)
)
)
[Point] => Array
(
[coordinates] => -90.1848103,32.2987573,0
)
)
[1] => Array
(
[@attributes] => Array
(
[id] => p2
)
[address] => Jackson, TN, USA
[AddressDetails] => Array
(
[@attributes] => Array
(
[Accuracy] => 4
)
[Country] => Array
(
[CountryNameCode] => US
[CountryName] => USA
[AdministrativeArea] => Array
(
[AdministrativeAreaName] => TN
[SubAdministrativeArea] => Array
(
[SubAdministrativeAreaName] => Madison
[Locality] => Array
(
[LocalityName] => Jackson
)
)
)
)
)
[ExtendedData] => Array
(
[LatLonBox] => Array
(
[@attributes] => Array
(
[north] => 35.7562880
[south] => 35.5402259
[east] => -88.7567579
[west] => -88.9204599
)
)
)
[Point] => Array
(
[coordinates] => -88.8139469,35.6145169,0
)
)
[2] => Array
(
[@attributes] => Array
(
[id] => p3
)
[address] => Jackson, WY, USA
[AddressDetails] => Array
(
[@attributes] => Array
(
[Accuracy] => 4
)
[Country] => Array
(
[CountryNameCode] => US
[CountryName] => USA
[AdministrativeArea] => Array
(
[AdministrativeAreaName] => WY
[SubAdministrativeArea] => Array
(
[SubAdministrativeAreaName] => Teton
[Locality] => Array
(
[LocalityName] => Jackson
)
)
)
)
)
[ExtendedData] => Array
(
[LatLonBox] => Array
(
[@attributes] => Array
(
[north] => 43.4912050
[south] => 43.4578330
[east] => -110.7377220
[west] => -110.8134730
)
)
)
[Point] => Array
(
[coordinates] => -110.7624282,43.4799291,0
)
)
[3] => Array
(
[@attributes] => Array
(
[id] => p4
)
[address] => Jackson, NJ, USA
[AddressDetails] => Array
(
[@attributes] => Array
(
[Accuracy] => 4
)
[Country] => Array
(
[CountryNameCode] => US
[CountryName] => USA
[AdministrativeArea] => Array
(
[AdministrativeAreaName] => NJ
[SubAdministrativeArea] => Array
(
[SubAdministrativeAreaName] => Ocean
[Locality] => Array
(
[LocalityName] => Jackson
)
)
)
)
)
[ExtendedData] => Array
(
[LatLonBox] => Array
(
[@attributes] => Array
(
[north] => 40.1723549
[south] => 39.9990330
[east] => -74.2415390
[west] => -74.4695430
)
)
)
[Point] => Array
(
[coordinates] => -74.3294444,40.1080556,0
)
)
[4] => Array
(
[@attributes] => Array
(
[id] => p5
)
[address] => Jackson, MI, USA
[AddressDetails] => Array
(
[@attributes] => Array
(
[Accuracy] => 4
)
[Country] => Array
(
[CountryNameCode] => US
[CountryName] => USA
[AdministrativeArea] => Array
(
[AdministrativeAreaName] => MI
[SubAdministrativeArea] => Array
(
[SubAdministrativeAreaName] => Jackson
[Locality] => Array
(
[LocalityName] => Jackson
)
)
)
)
)
[ExtendedData] => Array
(
[LatLonBox] => Array
(
[@attributes] => Array
(
[north] => 42.2708699
[south] => 42.2036839
[east] => -84.3568169
[west] => -84.4345460
)
)
)
[Point] => Array
(
[coordinates] => -84.4013462,42.2458690,0
)
)
[5] => Array
(
[@attributes] => Array
(
[id] => p6
)
[address] => Jackson, WI, USA
[AddressDetails] => Array
(
[@attributes] => Array
(
[Accuracy] => 4
)
[Country] => Array
(
[CountryNameCode] => US
[CountryName] => USA
[AdministrativeArea] => Array
(
[AdministrativeAreaName] => WI
[SubAdministrativeArea] => Array
(
[SubAdministrativeAreaName] => Washington
[Locality] => Array
(
[LocalityName] => Jackson
)
)
)
)
)
[ExtendedData] => Array
(
[LatLonBox] => Array
(
[@attributes] => Array
(
[north] => 43.3387369
[south] => 43.3090429
[east] => -88.1422039
[west] => -88.1917450
)
)
)
[Point] => Array
(
[coordinates] => -88.1667599,43.3238919,0
)
)
[6] => Array
(
[@attributes] => Array
(
[id] => p7
)
[address] => Jackson, CA, USA
[AddressDetails] => Array
(
[@attributes] => Array
(
[Accuracy] => 4
)
[Country] => Array
(
[CountryNameCode] => US
[CountryName] => USA
[AdministrativeArea] => Array
(
[AdministrativeAreaName] => CA
[SubAdministrativeArea] => Array
(
[SubAdministrativeAreaName] => Amador
[Locality] => Array
(
[LocalityName] => Jackson
)
)
)
)
)
[ExtendedData] => Array
(
[LatLonBox] => Array
(
[@attributes] => Array
(
[north] => 38.3721550
[south] => 38.3302920
[east] => -120.7489930
[west] => -120.7981980
)
)
)
[Point] => Array
(
[coordinates] => -120.7741018,38.3488023,0
)
)
[7] => Array
(
[@attributes] => Array
(
[id] => p8
)
[address] => Jackson, GA, USA
[AddressDetails] => Array
(
[@attributes] => Array
(
[Accuracy] => 4
)
[Country] => Array
(
[CountryNameCode] => US
[CountryName] => USA
[AdministrativeArea] => Array
(
[AdministrativeAreaName] => GA
[SubAdministrativeArea] => Array
(
[SubAdministrativeAreaName] => Butts
[Locality] => Array
(
[LocalityName] => Jackson
)
)
)
)
)
[ExtendedData] => Array
(
[LatLonBox] => Array
(
[@attributes] => Array
(
[north] => 33.3114890
[south] => 33.2638330
[east] => -83.9354860
[west] => -84.0105969
)
)
)
[Point] => Array
(
[coordinates] => -83.9660209,33.2945651,0
)
)
[8] => Array
(
[@attributes] => Array
(
[id] => p9
)
[address] => Jackson, OH 45640, USA
[AddressDetails] => Array
(
[@attributes] => Array
(
[Accuracy] => 4
)
[Country] => Array
(
[CountryNameCode] => US
[CountryName] => USA
[AdministrativeArea] => Array
(
[AdministrativeAreaName] => OH
[SubAdministrativeArea] => Array
(
[SubAdministrativeAreaName] => Jackson
[Locality] => Array
(
[LocalityName] => Jackson
)
)
)
)
)
[ExtendedData] => Array
(
[LatLonBox] => Array
(
[@attributes] => Array
(
[north] => 39.0669040
[south] => 39.0062730
[east] => -82.5949490
[west] => -82.7069350
)
)
)
[Point] => Array
(
[coordinates] => -82.6365536,39.0520169,0
)
)
[9] => Array
(
[@attributes] => Array
(
[id] => p10
)
[address] => Jackson, MO, USA
[AddressDetails] => Array
(
[@attributes] => Array
(
[Accuracy] => 4
)
[Country] => Array
(
[CountryNameCode] => US
[CountryName] => USA
[AdministrativeArea] => Array
(
[AdministrativeAreaName] => MO
[SubAdministrativeArea] => Array
(
[SubAdministrativeAreaName] => Cape Girardeau
[Locality] => Array
(
[LocalityName] => Jackson
)
)
)
)
)
[ExtendedData] => Array
(
[LatLonBox] => Array
(
[@attributes] => Array
(
[north] => 37.4139659
[south] => 37.3385089
[east] => -89.5972280
[west] => -89.7035499
)
)
)
[Point] => Array
(
[coordinates] => -89.6662063,37.3822732,0
)
)
)
)
//數據爲單個結果從這裏開始
Array
(
[Response] => Array
(
[name] => 10121
[Status] => Array
(
[code] => 200
[request] => geocode
)
[Placemark] => Array
(
[@attributes] => Array
(
[id] => p1
)
[address] => Manhattan, NY 10121, USA
[AddressDetails] => Array
(
[@attributes] => Array
(
[Accuracy] => 5
)
[Country] => Array
(
[CountryNameCode] => US
[CountryName] => USA
[AdministrativeArea] => Array
(
[AdministrativeAreaName] => NY
[DependentLocality] => Array
(
[DependentLocalityName] => Manhattan
[PostalCode] => Array
(
[PostalCodeNumber] => 10121
)
)
)
)
)
[ExtendedData] => Array
(
[LatLonBox] => Array
(
[@attributes] => Array
(
[north] => 40.7528519
[south] => 40.7489381
[east] => -73.9917906
[west] => -73.9947563
)
)
)
[Point] => Array
(
[coordinates] => -73.9917906,40.7492821,0
)
)
)
)
//單結果數據到此爲止
我嘗試了想要的結果下面的代碼,但沒有成功
foreach ($array as $xm) {
foreach ($xm as $points=>$pointkey) {
foreach($pointkey as $cor=>$corkey) {
echo $cor["coordinates"];
}
}
}
它給了我警告「警告:爲foreach()在foreach中提供的無效參數($ pointkey爲$ cor => $ corkey)」
那麼你真的嘗試過自己?還是你只是希望有人會爲你做你的工作? – 2012-02-01 09:38:54
另外我沒有看到一個真正的問題,*座標*都位於相同的位置,只是寫一個foreach循環,並收集值? – Yoshi 2012-02-01 09:44:53
@Yoshi你能告訴我什麼是我的foreach循環? – dave 2012-02-01 09:45:52