从json数组PHP获取数组值

时间:2018-01-06 12:34:59

标签: php arrays json google-maps

我正在使用google place json array

json array

我正在使用此代码获取地点名称

 $string = file_get_contents("https://maps.googleapis.com/maps/api/place/nearbysearch/json?location=-33.8670522,151.1957362&rankby=distance&types=food&key=AIzaSyCpOG91fkAzPTZiFq7G9HbLfbmVyW8Wgyc");
$json_a = json_decode($string, true);

echo print_r(array_values($json_a-> results[0]->name[0]));

但结果总是{ 1 },结果应为 Biaggio Cafe

如果我打印出数组 print_r($ json_a)

Array ( [html_attributions] => Array ( ) [next_page_token] => CqQCFwEAAN1f0rbnMkVsdezGGV9kDlKiYdkDKgOSeaul7JL6GFEeLhV0-h3_WHa0NGbQ_here u_N7K3e7r5xxtW4FGjp6dHK4WKxUb1LPbmLq4KvybiR7QyYspK6wHC4In7Slnhj_0veXd25lruweEKFTmnu6fX0JUN3Lwtyz4KnQrnGeJHX7Ldr6oWJcSn-ilM2AXCQi0LnFza4dJmlvh62Eq583kQ5s1WQO8VrnQ8G66Yfy69X7Glbe0Pijj384gSWncN6kEbEUAw_PyHe4R3z50MRa336ZpzTxOulRwjV6NtNtUbn-j-omj0fb2Q0Yf6QQRrmiAaKx2QqYaN3AB7oH1YouLKLyGVzA3qOoIdYmI3OAztgkPKWUlNl5PzS3Ro7V8g-RdNN0hIQTtLlDEzmNPviMy1X28gkHBoUQxlMdi3EX_zrQzljRF12sjVab2c [results] => Array ( [0] => Array ( [geometry] => Array ( [location] => Array ( [lat] => -33.8669667 [lng] => 151.1958862 ) [viewport] => Array ( [northeast] => Array ( [lat] => -33.865664669709 [lng] => 151.19708633029 ) [southwest] => Array ( [lat] => -33.868362630292 [lng] => 151.19438836971 ) ) ) [icon] => https://maps.gstatic.com/mapfiles/place_api/icons/cafe-71.png [id] => 7eaf747a3f6dc078868cd65efc8d3bc62fff77d7 [name] => Biaggio Cafe [opening_hours] => Array ( [open_now] => [weekday_text] => Array ( ) ) [photos] => Array ( [0] => Array ( [height] => 3036 [html_attributions] => Array ( [0] => Briggs Soria ) [photo_reference] => CmRaAAAAcPXEEuCbXQiIU-c0rFzFwHhpmRPEDkZ-7D6ep2gpkEG8Yyx6-aB6o4cp2LWce728a-Eb9izN9ju-TAe6sdURdcpX-UpJwMHR7Ynj1H4HYy7R4WUWtqxbN7hifOWqV6TzEhD0g0k5X-KCKBu9RdWpl-47GhQwPBWXcBL0LnMWEp9ItV7REPcmTQ [width] => 4048 ) ) [place_id] => ChIJIfBAsjeuEmsRdgu9Pl1Ps48 [price_level] => 1 [rating] => 3 [reference] => CmRSAAAAiI3HIH3xQoIx0spB-d1aye7c7W4L3s25RxdAHwwLVEvC5AovkxwscFsfi-1ZKAL9V-DAPda5d9FH_ywnl7Ll3vovPw5v6T08uNxVwJyMn9MPJFHWZN06dJT1f50vZ19qEhBfOVCaYhc8f9tk2UZLkgAOGhSSKLENUQ1taZOQWolQVsJ0V48bQA [scope] => GOOGLE [types] => Array ( [0] => cafe [1] => restaurant [2] => food [3] => store [4] => point_of_interest [5] => establishment ) [vicinity] => 48 Pirrama Road, Pyrmont ) [1] => Array ( [geometry] => Array ( [location] => Array ( [lat] => -33.8671288 [lng] => 151.195339 ) [viewport] => Array ( [northeast] => Array ( [lat] => -33.866065569709 [lng] => 151.1960316 ) [southwest] => Array ( [lat] => -33.868763530292 [lng] => 151.1932612 ) ) ) [icon] => https://maps.gstatic.com/mapfiles/place_api/icons/restaurant-71.png [id] => 8bdf85385635caa3b9df55ec23d533ceb0f2b8c6 [name] => The Century [opening_hours] => Array ( [open_now] => 1 [weekday_text] => Array ( ) ) [photos] => Array ( [0] => Array ( [height] => 1989 [html_attributions] => Array ( [0] => The Century ) [photo_reference] => CmRaAAAAbC2XEW4KdedbESdFb1Bgija2OV_9mR8t6DJqMZwmLjwXAtG5JgWYfzUi7nEx0ZKqhhsDxtPceC3MPKbYJIVh7VWT_CDvsN7hRtW2bdpxss87I9DbTn450Vd7dn0wOueWEhBGiONsANF-eOu1xwrVMXP4GhTqtBdrIP84yK19IXGwZVqazpEACQ [width] => 2048 ) ) [place_id] => ChIJ1-v38TauEmsRNrXszdcSywQ [price_level] => 2 [rating] => 3.5 [reference] => CmRRAAAAyJYatPQTSvqMbOt1gIhNxfc1Sy7fnXKDBaX0lYkx16_u2HEu8hyBH_XriKc1Aciq3Gx8FxQI_OkXxRTFh2xz8eJbV8lOA6gFoMxDbvV3nQN2yCAwwgwo60wTKavRnxcOEhBT6whUoikUKFrq4EXRcK4OGhRgUy8KHjA9IS8ckfED_CNkdScvvg [scope] => GOOGLE [types] => Array ( [0] => restaurant [1] => food [2] => point_of_interest [3] => establishment ) [vicinity] => The Star, 80 Pyrmont Street, Pyrmont ) [2] => Array ( [geometry] => Array ( [location] => Array ( [lat] => -33.8667062 [lng] => 151.1957844 ) [viewport] => Array ( [northeast] => Array ( [lat] => -33.865427419709 [lng] => 151.19697313029 ) [southwest] => Array ( [lat] => -33.868125380292 [lng] => 151.19427516971 ) ) ) [icon] => https://maps.gstatic.com/mapfiles/place_api/icons/cafe-71.png [id] => fd0f490655de01f49b604781f944340f6623d1b1 [name] => Biaggio Cafe [opening_hours] => Array ( [open_now] => [weekday_text] => Array ( ) ) [place_id] => ChIJA0NrtTeuEmsRkmB_OMsgGOw [reference] => CmRSAAAANgrbbAHDKaIJ1OR0BFJ6t2Jlk0fKKDN9-hnfaDtSU2Xirm_66SOV4Wpy_w7HL6WVv0JXy4vrUdWkLMVizwGS1XpjSqDs-M6WbzSyGr6C-gJdLCUwDMPf6RBpCfeo279REhApljm2GRCvCVzFqcZ0pkGqGhRttJFZd6bXU67b3i-YN-N7ucP2oA [scope] => GOOGLE [types] => Array ( [0] => cafe [1] => restaurant [2] => food [3] => point_of_interest [4] => establishment ) [vicinity] => 48 Pirrama Road, Pyrmont ) [3] => Array ( [geometry] => Array ( [location] => Array ( [lat] => -33.8667062 [lng] => 151.1957844 ) [viewport] => Array ( [northeast] => Array ( [lat] => -33.865357219708 [lng] => 151.19713338029 ) [southwest] => Array ( [lat] => -33.868055180291 [lng] => 151.19443541971 ) ) ) [icon] => https://maps.gstatic.com/mapfiles/place_api/icons/generic_business-71.png [id] => 3ef986cd56bb3408bc1cf394f3dad9657c1d30f6 [name] => Doltone House - Darling Island Wharf [opening_hours] => Array ( [open_now] => [weekday_text] => Array ( ) ) [photos] => Array ( [0] => Array ( [height] => 843 [html_attributions] => Array ( [0] => Doltone House - Darling Island Wharf ) [photo_reference] => CmRaAAAAkdwvY7mKPHP6aCqmXjNPithGEIBaytETIG8GtU70vtAsymKWMaYhw4-VW6_W3HKyH9ddeVjnRFWwmWFlZO2yNLZ8IPDGmPSbqqtA4TzwZL9XddUH1eBGg-BhlicwYUTYEhAnqcUR2JQcwa8O54DUD1_XGhRGg60_1NqarQ1UbtXiJzaPq5MtxA [width] => 1500 ) ) [place_id] => ChIJ5xQ7szeuEmsRs6Kj7YFZE9k [rating] => 4.2 [reference] => CmRSAAAAVzanf0yiJg-X4Y2F94Wj-SjxZLi7i4zwrXM-0mEkXgmzelK7Jus6fGWbKsqeGH8fSbzn8oNBGhyV5VvewU4AXFoUx5uMjrg6A5Ho8vccsfL0Dq5PMReQiXYUKYBDoXPNEhCmcU6_Vat2qDmjKaPtJIeYGhT2c8QasUnZCrUQpd_RFUO1_Jf6lQ [scope] => GOOGLE [types] => Array ( [0] => food [1] => point_of_interest [2] => establishment ) [vicinity] => Ground Floor, 48 Pirrama Rd, Pyrmont ) [4] => Array ( [geometry] => Array ( [location] => Array ( [lat] => -33.8667062 [lng] => 151.1957844 ) [viewport] => Array ( [northeast] => Array ( [lat] => -33.865357219708 [lng] => 151.19713338029 ) [southwest] => Array ( [lat] => -33.868055180291 [lng] => 151.19443541971 ) ) ) [icon] => https://maps.gstatic.com/mapfiles/place_api/icons/generic_business-71.png [id] => 2de2d85c0465dafc9a75e0304859c5ceedb4a679 [name] => Signorelli Gastronomia [opening_hours] => Array ( [open_now] => [weekday_text] => Array ( ) ) [photos] => Array ( [0] => Array ( [height] => 390 [html_attributions] => Array ( [0] => Signorelli Gastronomia ) [photo_reference] => CmRaAAAA5VEkXQg5NXRvvbjQ-sHCF1rusIPBRItqIXb7ctqawTC8_ZG4b0zPBGBLSA8ttYHp1D2DFFaqT0WtsXLT0tmSBXnJ47-Ei94jKjg5jCIpWt5dlweWMMyx5duOEBNB2biLEhBZqLCcaoSa2tVU6zZEWewGGhQ9JSj_mVqMDeizYtrcYVaCYVz6sQ [width] => 960 ) ) [place_id] => ChIJFcJDMzauEmsRy81NJCujoY8 [price_level] => 2 [rating] => 3.9 [reference] => CmRSAAAAJcg6WX2L8zTXoizEVUB5lyaKW22-sMoMsiOBaT8Oa4stB2PrbrObqZ2boBIIR8xxpyFIpf7q-HZuuDp3oXJ4Wa964l1koOq7jEjk7l_2wFHWdAsEF0ekpmvZV4rTC_nTEhAfwAlxYeqXvgmAL5vBlEjuGhSkxSkyhxCJOZo2gr4lUa7YU5NSww [scope] => GOOGLE [types] => Array ( [0] => food [1] => point_of_interest [2] => establishment ) [vicinity] => Ground Floor, 48 Pirrama Road, Pyrmont ) [5] => Array ( [geometry] => Array ( [location] => Array ( [lat] => -33.8664812 [lng] => 151.196061 ) [viewport] => Array ( [northeast] => Array ( [lat] => -33.865132219708 [lng] => 151.19740998029 ) [southwest] => Array ( [lat] => -33.867830180291 [lng] => 151.19471201971 ) ) ) [icon] => https://maps.gstatic.com/mapfiles/place_api/icons/restaurant-71.png [id] => 91509349e192972859b886e62f11827e5bd0072f [name] => Esky Cafe [opening_hours] => Array ( [open_now] => [weekday_text] => Array ( ) ) [photos] => Array ( [0] => Array ( [height] => 1536 [html_attributions] => Array ( [0] => Paul Toogood ) [photo_reference] => CmRaAAAAWHv_VoJ9mDttpdl8XXeM78_bDtutVfhNIwoz57Va1CEzOrxzN5XAtuu1OwzwU8NoH6prpkLzdALY0DhdKz4reJkejB_AV4NYrbFbztRRG5xcJGthqTHOzzdDXzBTkPk-EhDVmJVlHn-tap_okguRQ4eKGhQ78ZojGOFEKHxpPeJGTBaNa68yDg [width] => 2048 ) ) [place_id] => ChIJm3d7yTeuEmsRC2wYUB24q9I [rating] => 4.4 [reference] => CmRSAAAAOEtb2LjP1kZkWxsgcq5mGm6NWlAlwMOTXQnF3HFvwRN9-cIl0-RJU8-nT3Jp8dRlib9o0M2U0JFauLwjjOw0fqPadh2OBVqGde8LqbzVP4FUIlmKR-lKOCuC1U8Fyw1QEhB0T-m_Jh_h4ooBbl4YxQQOGhQC_bkk9d2Fyraihp5Q6-njdS1QEg [scope] => GOOGLE [types] => Array ( [0] => restaurant [1] => cafe [2] => food [3] => point_of_interest [4] => establishment ) [vicinity] => Workplace 6, 48 Pirrama Road, Pyrmont ) [6] => Array ( [geometry] => Array ( [location] => Array ( [lat] => -33.8677499 [lng] => 151.1956285 ) [viewport] => Array ( [northeast] => Array ( [lat] => -33.866673069708 [lng] => 151.19631778029 ) [southwest] => Array ( [lat] => -33.869371030291 [lng] => 151.19361981971 ) ) ) [icon] => https://maps.gstatic.com/mapfiles/place_api/icons/restaurant-71.png [id] => b21cfc23b85bda32717dc32bbb3b0d290e1692bf [name] => Kampung [opening_hours] => Array ( [open_now] => [weekday_text] => Array ( ) ) [place_id] => ChIJ1-v38TauEmsRkfBaAXNA5LI [rating] => 5 [reference] => CmRSAAAAh9Vuux8EylTbKIFyoWDxeWXxXHp8fsNM7Q97h8W9_TxvAo23lTjahLW0vGFAnlmHG3qIu4WXfo5XlgS42tQIsp5RiAiFiuqLtlXX1uRI4JxJrpi3oSxCp75fRlxGJsgrEhB2JLQK_7pdw-RhP6XDi12XGhTcmREuPiKty8znAmNvc1VPE2Unvg [scope] => GOOGLE [types] => Array ( [0] => restaurant [1] => meal_takeaway [2] => food [3] => point_of_interest [4] => establishment ) [vicinity] => 80 Pyrmont Street, Pyrmont ) [7] => Array ( [geometry] => Array ( [location] => Array ( [lat] => -33.8677499 [lng] => 151.1956285 ) [viewport] => Array ( [northeast] => Array ( [lat] => -33.866673069708 [lng] => 151.19631778029 ) [southwest] => Array ( [lat] => -33.869371030291 [lng] => 151.19361981971 ) ) ) [icon] => https://maps.gstatic.com/mapfiles/place_api/icons/restaurant-71.png [id] => f67efa5095d123ed2c1ce28e9297cc1e04624dc8 [name] => Lotus Pond [opening_hours] => Array ( [open_now] => 1 [weekday_text] => Array ( ) ) [place_id] => ChIJS_-h7TauEmsRdmDJ2CvXToY [rating] => 3.2 [reference] => CmRSAAAApnMGhFr1SKg2H4LpIDfJXqOAy2OUDSy_NaWA6ZOetI47fBG-Un_heBunbN2ozjyuhac5z7MHXOCwlGchZRpOJtOJupqfhOHGP93S2fvSTUt8nLUUo39WKBvpHUMrfCKmEhBuSr4HMwgKwUJkpjT5ffUnGhRQejzefZ3S3vCStqCxF8wAlBt1JQ [scope] => GOOGLE [types] => Array ( [0] => restaurant [1] => food [2] => point_of_interest [3] => establishment ) [vicinity] => 80 Pyrmont Street, Pyrmont ) [8] => Array ( [geometry] => Array ( [location] => Array ( [lat] => -33.8677499 [lng] => 151.1956285 ) [viewport] => Array ( [northeast] => Array ( [lat] => -33.866673069708 [lng] => 151.19631778029 ) [southwest] => Array ( [lat] => -33.869371030291 [lng] => 151.19361981971 ) ) ) [icon] => https://maps.gstatic.com/mapfiles/place_api/icons/bar-71.png [id] => 882abf952e4d0e6dd96294459abe076c90c127dd [name] => 24/7 Sports Bar [opening_hours] => Array ( [open_now] => 1 [weekday_text] => Array ( ) ) [photos] => Array ( [0] => Array ( [height] => 638 [html_attributions] => Array ( [0] => 24/7 Sports Bar ) [photo_reference] => CmRaAAAAYsUMTqwU7RRG7gB1ft1yChuVhIvF4_TZ1NBRyyQdQs163bRXTh0X2ZJ_4AzjnNQztgZgOFxieDONaMGfqBlfQ3GWjgMFPZ3m-Ut-UsumAyDi2FQoo25vDBp58CA2kfdwEhDhNViiTe0vPZz2FgiFPphqGhTx1ZfQLwYRebnXV4I0q8yS1VF1Sg [width] => 960 ) ) [place_id] => ChIJ77Cd7TauEmsRBV42CMtSans [rating] => 3.4 [reference] => CmRRAAAANyqljC8u7sy67zaoKmvy1yZF9BJcoCO4UBwiC0F6WIPMkhZo84UbBiyR_bngCy8mziKacKR7hqOmH0C5YqJryYPNSpHqeTahBB84i7wnezFrFYklzHCjDTt_DhDFW96mEhBXRQVuWptLLxd9XRES6X3pGhQF3k1348GfUaIlUVmFiE06ERWP6w [scope] => GOOGLE [types] => Array ( [0] => bar [1] => restaurant [2] => food [3] => point_of_interest [4] => establishment ) [vicinity] => 80 Pyrmont Street, Pyrmont ) [9] => Array ( [geometry] => Array ( [location] => Array ( [lat] => -33.8677499 [lng] => 151.1956285 ) [viewport] => Array ( [northeast] => Array ( [lat] => -33.866673069708 [lng] => 151.19631778029 ) [southwest] => Array ( [lat] => -33.869371030291 [lng] => 151.19361981971 ) ) ) [icon] => https://maps.gstatic.com/mapfiles/place_api/icons/restaurant-71.png [id] => e188acf29a29bc46f1cf844c0bf78f8b1464bd6f [name] => BLACK Bar & Grill [opening_hours] => Array ( [open_now] => [weekday_text] => Array ( ) ) [photos] => Array ( [0] => Array ( [height] => 2160 [html_attributions] => Array ( [0] => Chopinand Mysaucepan ) [photo_reference] => CmRaAAAAwz1MNHctvLtTgc7iFYmuDljnVuWyKnajNBh0z24Il7cTm7TAiJlAlnzvsgUp5JVULO8_oPFxW6DkjKLqN-MI0T703nJzFYGT79Yx36tJxuZaBAkZ5xIAis7T51pXYQ-wEhCupMDWqDDxv_3YsfJZnsQPGhQBp2vGHZWl6ECDGdoGt17Hz28PJg [width] => 3232 ) ) [place_id] => ChIJ9ZCzFzGuEmsR_EwB_qra-W4 [rating] => 4.1 [reference] => CmRRAAAAkRe25ds64LLF7mzx0Qdiy-d2kqa1WQzeNHH6_SsiDeZFdzjorMWenC7z4VRTw7BdNocoPzjqb6AjICSKQZCR6fW_xVHmsEUQNJseFAJ-6hDlgv2PpoBJ9pU5PnK221T3EhBJ3CwsMrtaSdukyZyDIpWvGhSeLY4vgz6nO6ZSW5bb0gcQsJxIOQ [scope] => GOOGLE [types] => Array ( [0] => restaurant [1] => bar [2] => food [3] => point_of_interest [4] => establishment ) [vicinity] => G, 80 Pyrmont Street, Pyrmont ) [10] => Array ( [geometry] => Array ( [location] => Array ( [lat] => -33.8677499 [lng] => 151.1956285 ) [viewport] => Array ( [northeast] => Array ( [lat] => -33.866673069708 [lng] => 151.19631778029 ) [southwest] => Array ( [lat] => -33.869371030291 [lng] => 151.19361981971 ) ) ) [icon] => https://maps.gstatic.com/mapfiles/place_api/icons/restaurant-71.png [id] => 8ed2a95d07a89918c0a1b846544a955b36820af3 [name] => Dergah Grill [opening_hours] => Array ( [open_now] => 1 [weekday_text] => Array ( ) ) [photos] => Array ( [0] => Array ( [height] => 992 [html_attributions] => Array ( [0] => Dergah Grill ) [photo_reference] => CmRaAAAAjsOwnxHbfcRXNSsW7sVFA88bbK7XoeeI8etp5i3Rkmfvw2Nv2oOGbVoJzNZrzUwBrFpTRv_pU27OzahrLlCUFFLGz-_P2Z7Hn4jH0waC4urQg18yPbyE2qHFXRAh2sF_EhBK6Dk08w1Z44NTsgzbBVSMGhRLCr0qizP00LjX_T6jUh_986vnWA [width] => 1487 ) ) [place_id] => ChIJ1-v38TauEmsR7cWnOpSlMWU [rating] => 3 [reference] => CmRRAAAAz-ES7KMUShGEIn28_6aURVGtGr3kEJR9SzWKTgvXo9QDYSJAIVSe2WD02y4H9aJEv3IXJUTl1wH4iMxivWmNwNNJoSCotqKo7Dky9K4dpVSKwSLJvyGA65G1tuHzswMzEhAz3rOaYTJh9qr42kVmFeFdGhQwYDAjO2IYp6ypv5ot-QFZvZzJOA [scope] => GOOGLE [types] => Array ( [0] => meal_takeaway [1] => restaurant [2] => food [3] => point_of_interest [4] => establishment ) [vicinity] => 80 Pyrmont Street, Pyrmont ) [11] => Array ( [geometry] => Array ( [location] => Array ( [lat] => -33.8677499 [lng] => 151.1956285 ) [viewport] => Array ( [northeast] => Array ( [lat] => -33.866673069708 [lng] => 151.19631778029 ) [southwest] => Array ( [lat] => -33.869371030291 [lng] => 151.19361981971 ) ) ) [icon] => https://maps.gstatic.com/mapfiles/place_api/icons/cafe-71.png [id] => 5895b175f4c2a8535294f5587fe089fc7d5135ea [name] => Pulse Express [opening_hours] => Array ( [open_now] => [weekday_text] => Array ( ) ) [photos] => Array ( [0] => Array ( [height] => 992 [html_attributions] => Array ( [0] => Pulse Express ) [photo_reference] => CmRaAAAAg1N3QTCieHLyOJE0-UsbTQJJnawb4ZTuoB_-WPf9Wz4fOQbtJGvRWbUnppV_RgKaq5heQuEMBGg9kI0iXGxrDVPOEnQ3Zyh-iLbge3xpuZyQI0mjS6BlvyxRdNPvn3lVEhChKRAL5I5nHP_QU_a7aJjWGhTlwb7eywRH-kh7dx-spnPvP4bUXA [width] => 1618 ) ) [place_id] => ChIJ1-v38TauEmsRJxe1QBBHBGU [rating] => 2.6 [reference] => CmRRAAAALsYqD7jAxdAy8zpoDEWxfFD9PFNlJdN8o-krm3fupp77oxNnP-fJJqvplpFIxWTFA1pjVwFG0ozgeao2PhoL0VoKPDT6Gy6qi56NKyusNn6eDkfzLctO3iDB4Dx_inomEhAjhFof0CLWU1vFJ4VMOfvjGhSVYSHLz7kQml-Ne-VJVJuawxywRg [scope] => GOOGLE [types] => Array ( [0] => cafe [1] => restaurant [2] => food [3] => point_of_interest [4] => establishment ) [vicinity] => 80 Pyrmont Street, Pyrmont ) [12] => Array ( [geometry] => Array ( [location] => Array ( [lat] => -33.8678337 [lng] => 151.1958116 ) [viewport] => Array ( [northeast] => Array ( [lat] => -33.866484719709 [lng] => 151.19716058029 ) [southwest] => Array ( [lat] => -33.869182680291 [lng] => 151.19446261971 ) ) ) [icon] => https://maps.gstatic.com/mapfiles/place_api/icons/restaurant-71.png [id] => f138865c7ac72dcc2cbd0491710aa6203ebc595f [name] => Pizzaperta [opening_hours] => Array ( [open_now] => 1 [weekday_text] => Array ( ) ) [photos] => Array ( [0] => Array ( [height] => 440 [html_attributions] => Array ( [0] => Pizzaperta ) [photo_reference] => CmRaAAAADCeKPVnBAGuxYOy03lNLG-7HuR5VQ6fBNFQmvJsCX52UBYB_wV4_450EskliO7fGWAwZ6mXhNLgonnqp0I9ixGFOeWzBuT2ChqPPoET9ofpKYiwNi9t4d7fl5NQTYyc5EhCxeM8QlMlbKP65Mku5ZAnDGhQR-zt6WCXpQXmhJ5gmXSdamamTWQ [width] => 700 ) ) [place_id] => ChIJA6-_qzeuEmsRiV9SAHIbzh4 [rating] => 3.4 [reference] => CmRRAAAAn-uUOFjUKSV18ENqqy65iOzr3Ea1H3ipK-9c3UX1IsTJPgb_-gd6d4BrsUIDcKZmwAnQZ8rtesI8jA0V46-9ovQh9RiGXmJsLrz3UyrKSxkhOuLXvFzyKu2z3Ja8QbGMEhDo-m7u5hyHfMmgPTcdKsWOGhRo5Fizn7eEefTbuOl9D8GfMAmX8A [scope] => GOOGLE [types] => Array ( [0] => restaurant [1] => food [2] => point_of_interest [3] => establishment ) [vicinity] => The Star Sydney, Harbourside Entry, Pirrama Rd, Pyrmont NSW 2009, Sydney ) [13] => Array ( [geometry] => Array ( [location] => Array ( [lat] => -33.867931 [lng] => 151.1958456 ) [viewport] => Array ( [northeast] => Array ( [lat] => -33.866582019709 [lng] => 151.19719458029 ) [southwest] => Array ( [lat] => -33.869279980292 [lng] => 151.19449661971 ) ) ) [icon] => https://maps.gstatic.com/mapfiles/place_api/icons/restaurant-71.png [id] => 372b98902d4032b2708939131b8bc6bfbce9044c [name] => Chao Praya City [place_id] => ChIJ1-v38TauEmsRwCiun0VT1Kg [rating] => 5 [reference] => CmRSAAAA4HOsgFazyJOqUAEAfPyuQif3apB-IrYQ_UVZTyvwYLm18txQlrvMOWcaZp98ggKyWEoA0ea17TSlUNwHxJt3YLAOY_Aj6JSaOtRWxl3HdIoGwFGpVzVo37OyXen7d5nCEhDy43UD1zpBwgahbZGtW7nBGhRiLaMA4r9IsOXzLTe7-tm-ZzDNRA [scope] => GOOGLE [types] => Array ( [0] => restaurant [1] => food [2] => point_of_interest [3] => establishment ) [vicinity] => P1 Level G Star City Pirrama Road, Pyrmont ) [14] => Array ( [geometry] => Array ( [location] => Array ( [lat] => -33.8680279 [lng] => 151.195857 ) [viewport] => Array ( [northeast] => Array ( [lat] => -33.866961369708 [lng] => 151.1965416 ) [southwest] => Array ( [lat] => -33.869659330291 [lng] => 151.1938032 ) ) ) [icon] => https://maps.gstatic.com/mapfiles/place_api/icons/restaurant-71.png [id] => 08c0f74375ca1956d8ae2919512171adcd8266d7 [name] => Balla [opening_hours] => Array ( [open_now] => [weekday_text] => Array ( ) ) [photos] => Array ( [0] => Array ( [height] => 2882 [html_attributions] => Array ( [0] => Cynthia Chia ) [photo_reference] => CmRaAAAAQ3bhhMFaAoi-XSdDMIl1abzVHbm92X575sZ--9E828fgDgt1va8s8to_iCVMjruKD-E2vECITkXW_hwBP9iS4NE8fJSyEj2ZrK6eCP5HAiafZJT0DUsRkiWxVQ66Ud8mEhBDEgwL9JaYlPOaTIlT81MpGhTK_Bmrs14OfusC2d7vJ3SoRIUiKw [width] => 3843 ) ) [place_id] => ChIJ1-v38TauEmsRFBHuvMmwNyA [price_level] => 3 [rating] => 3.7 [reference] => CmRRAAAAxa4gkSU26kt1A9BMsaxySAdOysJGpreX08qD8FY-w40v6J36GYo1xIZJ9vy-T8zbjNLXr1PEXD458O72KpZr83kNlEuZIMYxQcodSdkAFtMJzbsaCCm2ldzYjeF-cDM1EhDLMSnhPjgnj33vJn13HV6GGhRNG8bcAGL_d9kMXxMMxfJjjGyffA [scope] => GOOGLE [types] => Array ( [0] => restaurant [1] => food [2] => point_of_interest [3] => establishment ) [vicinity] => The Star, G, 80 Pyrmont Street, Pyrmont ) [15] => Array ( [geometry] => Array ( [location] => Array ( [lat] => -33.8679022 [lng] => 151.1951276 ) [viewport] => Array ( [northeast] => Array ( [lat] => -33.866727419708 [lng] => 151.19605433029 ) [southwest] => Array ( [lat] => -33.869425380291 [lng] => 151.19335636971 ) ) ) [icon] => https://maps.gstatic.com/mapfiles/place_api/icons/cafe-71.png [id] => 0761a21e23eda2598330d428413cb59431316a61 [name] => Lobby Lounge [opening_hours] => Array ( [open_now] => 1 [weekday_text] => Array ( ) ) [photos] => Array ( [0] => Array ( [height] => 1632 [html_attributions] => Array ( [0] => Andrei Setiawan Yohannes ) [photo_reference] => CmRaAAAA5WtwRlnY-IB_agGsXdnruKoylr826EKf-vmptRBP68TXnQPuT5DPGByyl9VCMiC-_tt7PGY-qVVoXQnEue-fS9S2oWyyiUoXA_XTnriNyC0TasEwfyqMI2tHnfEn4r_5EhBZpIz5HXkqmqBK6HQhxQ4yGhRBLF-Xg9yILQPoB8KW4bT6xJn1Ag [width] => 920 ) ) [place_id] => ChIJ1-v38TauEmsRHbUt24abGq8 [rating] => 3.9 [reference] => CmRSAAAALvC6LDeHGtKa-1BfrK8GxGZJms5-W23jkxgNHUNfUAWST9IIfNzcqPKy7MMuaLztr5sIZpIiEs5YBhM4PtAccuBSdJSx5LaWK-E5ObIs_LZPCwtOikhG0NMtAf6D_hbpEhD2eT7U7sfSDnKg98_RWkd8GhQD3C5E8vTUxAO_p1GxO7w5oYtcCw [scope] => GOOGLE [types] => Array ( [0] => cafe [1] => food [2] => store [3] => point_of_interest [4] => establishment ) [vicinity] => 80 Pyrmont Street, Pyrmont ) [16] => Array ( [geometry] => Array ( [location] => Array ( [lat] => -33.8679658 [lng] => 151.1952022 ) [viewport] => Array ( [northeast] => Array ( [lat] => -33.866350469709 [lng] => 151.19779985 ) [southwest] => Array ( [lat] => -33.869048430291 [lng] => 151.19280965 ) ) ) [icon] => https://maps.gstatic.com/mapfiles/place_api/icons/lodging-71.png [id] => 44fdc977984610cd873c790a7d850e8185ed0e5e [name] => The Star Sydney [opening_hours] => Array ( [open_now] => 1 [weekday_text] => Array ( ) ) [photos] => Array ( [0] => Array ( [height] => 1978 [html_attributions] => Array ( [0] => The Star Sydney ) [photo_reference] => CmRaAAAAAKL4p8pfqn9KTX1IP4mC6wbRpfJB2R8wdaAT7y6fmdLL8-5XIdgggJp31eE9S0tJQbifbUqDCCjqH1YK74u2ezYck-6_m7MB7FG9fBCKcW_gv5Utyt5nHcC2IiW7GpfFEhCNnJ_cBhkAaSf9vcmYiQ0SGhROkORa05CJzj2d8kBLLRdg6q39OA [width] => 2048 ) ) [place_id] => ChIJq6qq6jauEmsRJAf7FjrKnXI [rating] => 4 [reference] => CmRRAAAAP2aFIXavvX5VXtZkh_BsYrNfKlzYMJS-LeoZWPUzOaY96nVOpuANmGxyBnS-A25653IYjCOBOqGpNTLYdUALm75rICJmk9BkV29IHuS11I-gKFgviOkQnjC-QDMU6NMOEhDvOnNCgVPkvBeXh5KWnKDGGhT5qVnYHznM3i7qGh_bvJ3Vv2uGBA [scope] => GOOGLE [types] => Array ( [0] => casino [1] => spa [2] => lodging [3] => restaurant [4] => food [5] => point_of_interest [6] => establishment ) [vicinity] => 80 Pyrmont Street, Pyrmont ) [17] => Array ( [geometry] => Array ( [location] => Array ( [lat] => -33.867978 [lng] => 151.195171 ) [viewport] => Array ( [northeast] => Array ( [lat] => -33.866802919708 [lng] => 151.19609848029 ) [southwest] => Array ( [lat] => -33.869500880291 [lng] => 151.19340051971 ) ) ) [icon] => https://maps.gstatic.com/mapfiles/place_api/icons/restaurant-71.png [id] => 7d4beb38f8a160ca1758002b846afbf713cfe432 [name] => Vantage, The Star [opening_hours] => Array ( [open_now] => 1 [weekday_text] => Array ( ) ) [photos] => Array ( [0] => Array ( [height] => 3024 [html_attributions] => Array ( [0] => Neek Woman ) [photo_reference] => CmRaAAAA09pV6Ak9le5QPb1Djz9eCeBAK1MaBhTjF_XWBw-OdOwDP3xY-vHGjnC7RK8lRUd6qZ6OFccb3woPGGZxL7C4v-MVThoMqRfbYVaET-GQoN6OgFFFXtluaR-fYSj2k_IFEhCPSwX1E1O_Bb2Pz49_GYvUGhSr70Gmld6MWqoTdMkgm00mkl4S4w [width] => 3024 ) ) [place_id] => ChIJ2fIN-TauEmsRj8cqw1d-YI0 [rating] => 4 [reference] => CmRSAAAALWJKfuthS5deCrLk_fBqSMVa_cXG5uBPDFrF5ifHvitgFsdOfhkzgW4-58x6qfRdm2m5kJE950tJ-z7w6V3K7eDqF8P00O-gJIfWQg6agRh3L-5WZdKvgqfMZd6JLmfOEhCNSI1TqwbYLWWT-xTs2mLHGhTeOfVM-lR9v9jMlJvPa7pqk_aucg [scope] => GOOGLE [types] => Array ( [0] => restaurant [1] => casino [2] => food [3] => point_of_interest [4] => establishment ) [vicinity] => 80 Pyrmont Street, Pyrmont ) [18] => Array ( [geometry] => Array ( [location] => Array ( [lat] => -33.8669724 [lng] => 151.1944552 ) [viewport] => Array ( [northeast] => Array ( [lat] => -33.865714269709 [lng] => 151.19589088029 ) [southwest] => Array ( [lat] => -33.868412230291 [lng] => 151.19319291971 ) ) ) [icon] => https://maps.gstatic.com/mapfiles/place_api/icons/shopping-71.png [id] => dd8ce7e0a6f502325a4a5f45abfa2e1dc3784e07 [name] => Ezy mart pyrmont [opening_hours] => Array ( [open_now] => 1 [weekday_text] => Array ( ) ) [photos] => Array ( [0] => Array ( [height] => 899 [html_attributions] => Array ( [0] => Ezy mart pyrmont ) [photo_reference] => CmRZAAAAxwL2stPwv920nCiDOd3qm8bUIZZ3DAolWumYyMOpjKSjo6kYnO_YDoHzWFICKERPnIPucrIbdOrP8oY06LKBkaVLWX9UwPiMugbCcpAt5bZjT2PDhnwT8S4fleleT4pFEhC47nMqVf_XsAOtVVK0quhkGhR4_lUCOwYmhQib9FhrxKpdTHWA8A [width] => 900 ) ) [place_id] => ChIJV37FXDauEmsRL6aHZGJ7Q04 [reference] => CmRRAAAAtFUKLoOXju5F3e6L_dVsuKxI2jeXsraJOdU9Ilzg2U66aJb-TSB9OacxmgovqGQhb6I9nUOIQnUmDdgJsPEaziy9xf7ztkNKMj1VemSjzLeFnF95SB0bUAyu0L25Fj-4EhC1FPac5lMJy-FmkPWdm5EyGhSlBzIOA3oqBAiszlxbCL7BTy4IRw [scope] => GOOGLE [types] => Array ( [0] => convenience_store [1] => food [2] => store [3] => point_of_interest [4] => establishment ) [vicinity] => 1/2 Jones Bay Road, Pyrmont ) [19] => Array ( [geometry] => Array ( [location] => Array ( [lat] => -33.868028 [lng] => 151.19521 ) [viewport] => Array ( [northeast] => Array ( [lat] => -33.866679019708 [lng] => 151.19655898029 ) [southwest] => Array ( [lat] => -33.869376980291 [lng] => 151.19386101971 ) ) ) [icon] => https://maps.gstatic.com/mapfiles/place_api/icons/restaurant-71.png [id] => ba9494fbebdb7e40f9a646aab93379212763195c [name] => Fat Noodle [opening_hours] => Array ( [open_now] => 1 [weekday_text] => Array ( ) ) [photos] => Array ( [0] => Array ( [height] => 469 [html_attributions] => Array ( [0] => Fat Noodle ) [photo_reference] => CmRaAAAA0zMsUGM3z6dLIJmGiOcA39rcUNhUSJJlNQAAqqEbQzOiWhTeYAAdfJsjB1aBIHtDysC3CJwyHxKXmpXweRBv2G0-60FZVdawXVRiTyA2KTnG-2qgAm6h9k2FfDIzhsUIEhB2XzrAKGRuxOEnCowpQ8i1GhT-FQbOYvsdFgdhR6QdRwBsOKjIrA [width] => 750 ) ) [place_id] => ChIJ1-v38TauEmsROWultgmCYW0 [price_level] => 1 [rating] => 3.2 [reference] => CmRRAAAAlCa7aYxV6SgfJZII_AqswB88Oo2q0--NWOibat1k2OuiuBenPkZ3IKbTB-d8iQg2AupBZxtaY4DuS27eE1YYNrlZ4kRk2G7IaY2j9uP73zpZNT7KS8ASw2ibmiCM9Y2hEhC2fpgHMn6HxPpTpDS-Sts2GhQB3NhqtuZKtouPwU4j0jXFlz0NzQ [scope] => GOOGLE [types] => Array ( [0] => restaurant [1] => food [2] => point_of_interest [3] => establishment ) [vicinity] => The Star, 80 Pyrmont Street, Pyrmont ) ) [status] => OK )

2 个答案:

答案 0 :(得分:0)

echo print_r(....);在某种程度上是多余的。 print_r它会以与echo类似的方式将结果自行打印到输出,并返回您正在打印的TRUE

来自documentation

mixed print_r ( mixed $expression [, bool $return = false ] )
     

当return参数为TRUE时,此函数将返回一个字符串。否则,返回值为TRUE。

要么不使用echo,要么将返回参数设置为TRUE

echo print_r($array, true);

答案 1 :(得分:0)

检查从调用中获取的json的结构,以便访问您想要执行的值。

$string = file_get_contents("https://maps.googleapis.com/maps/api/place/nearbysearch/json?location=-33.8670522,151.1957362&rankby=distance&types=food&key=AIzaSyCpOG91fkAzPTZiFq7G9HbLfbmVyW8Wgyc");
$json_a = json_decode($string, true);

print_r($json_a['results'][0]['name']));

结果是一个数组,您想要访问其第一个元素([0])。从第一个元素中获取属性名称。并且元素上的所有属性都在数组中设置,因此您需要通过属性名称来访问它。

您使用对象运算符(->)来访问数组中的元素,这就是它无效的原因。