Getting the distance between two locations using Google Maps Api (JSON) - php

I want to get the distance between two locations using the Google API however this is the first time I hear about JSON and actually see its format. The variable $json_a should decode the JSON but when I try to get the distance I get "Notice: Undefined index: legs in C:\xampp\htdocs\app2\test.php on line 24". I added a link so you can see how the JSON structure looks like. I'll also want these locations ordered by distance and if you can provide any tips about how I could do that it would be great. Thanks! :)
PS: I know MySQL is depreciated, I'll look into MySQLi or PDO ASAP.
//$origin = $_COOKIE['origin'];
//$id=$_GET['id'];
$origin = "Bucuresti+Avrig+30";
$id = 3;
$query = ("SELECT * FROM locations WHERE category_id='$id'");
$result = mysql_query($query) or die (mysql_error());
while($row = mysql_fetch_array($result))
{
$address = $row['Judet'] . '+' . $row['Localitate'] . '+' . $row['Strada'] . '+' . $row['Numar'];
$address = str_replace(' ', '+', $address);
$fullurl = 'http://maps.googleapis.com/maps/api/directions/json?origin=' . $origin . '&destination=' . $address . '&alternatives=true&sensor=true';
$json_a = json_decode((file_get_contents($fullurl)),true);
echo $row['name'];
echo "<span class='badge'>" . $json_a['legs']['routes']['distance']['text'] . "</span></button>";
}
http://maps.googleapis.com/maps/api/directions/json?origin=Comanesti+Dimitrie+Ghica+13&destination=Brasov+1+Mai&alternatives=true&sensor=true
print_r shows me this:
Array ( [routes] => Array ( ) [status] => NOT_FOUND ) Array ( [routes] => Array ( [0] => Array ( [bounds] => Array ( [northeast] => Array ( [lat] => 44.4521487 [lng] => 26.1311305 ) [southwest] => Array ( [lat] => 44.4451446 [lng] => 26.1251047 ) ) [copyrights] => Map data ©2015 Google [legs] => Array ( [0] => Array ( [distance] => Array ( [text] => 1.2 km [value] => 1168 ) [duration] => Array ( [text] => 2 mins [value] => 137 ) [end_address] => Șoseaua Colentina 2, București, Romania [end_location] => Array ( [lat] => 44.4521487 [lng] => 26.1267169 ) [start_address] => Strada Avrig 30, București, Romania [start_location] => Array ( [lat] => 44.4451446 [lng] => 26.1311305 ) [steps] => Array ( [0] => Array ( [distance] => Array ( [text] => 0.4 km [value] => 397 ) [duration] => Array ( [text] => 1 min [value] => 42 ) [end_location] => Array ( [lat] => 44.4479077 [lng] => 26.1279682 ) [html_instructions] => Head northwest on Strada Avrig toward Aleea Avrig [polyline] => Array ( [points] => cugnGqvn~Ce#h#w#`AEDiArA_BnBm#r#QRsA~AeAlAaAjA ) [start_location] => Array ( [lat] => 44.4451446 [lng] => 26.1311305 ) [travel_mode] => DRIVING ) [1] => Array ( [distance] => Array ( [text] => 0.2 km [value] => 158 ) [duration] => Array ( [text] => 1 min [value] => 22 ) [end_location] => Array ( [lat] => 44.447097 [lng] => 26.1263385 ) [html_instructions] => Turn left onto Strada Chiristigiilor [maneuver] => turn-left [polyline] => Array ( [points] => mfhnGybn~CJTj#rAZv#Rh#f#nAPh# ) [start_location] => Array ( [lat] => 44.4479077 [lng] => 26.1279682 ) [travel_mode] => DRIVING ) [2] => Array ( [distance] => Array ( [text] => 0.3 km [value] => 282 ) [duration] => Array ( [text] => 1 min [value] => 32 ) [end_location] => Array ( [lat] => 44.4494197 [lng] => 26.1251047 ) [html_instructions] => Turn right onto Șoseaua Mihai Bravu [maneuver] => turn-right [polyline] => Array ( [points] => kahnGsxm~CiA#mAX[FGBMDWHEBc#Pa#T]TUPEBgBfB ) [start_location] => Array ( [lat] => 44.447097 [lng] => 26.1263385 ) [travel_mode] => DRIVING ) [3] => Array ( [distance] => Array ( [text] => 0.3 km [value] => 331 ) [duration] => Array ( [text] => 1 min [value] => 41 ) [end_location] => Array ( [lat] => 44.4521487 [lng] => 26.1267169 ) [html_instructions] => Turn right onto Șoseaua Colentina/DN2/E60/E85
Destination will be on the right
[maneuver] => turn-right [polyline] => Array ( [points] => {ohnG{pm~CYE[IoBk#oFeDYWYQq#[e#[ ) [start_location] => Array ( [lat] => 44.4494197 [lng] => 26.1251047 ) [travel_mode] => DRIVING ) ) [via_waypoint] => Array ( ) ) ) [overview_polyline] => Array ( [points] => cugnGqvn~CaL|MgCxCv#hBn#`Bx#xBiA#mAXc#JoAd#{A`AgBfBYEkCu#iG}DkAm#e#[ ) [summary] => Strada Avrig and Șoseaua Colentina/DN2/E60/E85 [warnings] => Array ( ) [waypoint_order] => Array ( ) ) [1] => Array ( [bounds] => Array ( [northeast] => Array ( [lat] => 44.4521487 [lng] => 26.131243 ) [southwest] => Array ( [lat] => 44.4438465 [lng] => 26.1251047 ) ) [copyrights] => Map data ©2015 Google [legs] => Array ( [0] => Array ( [distance] => Array ( [text] => 1.3 km [value] => 1282 ) [duration] => Array ( [text] => 3 mins [value] => 153 ) [end_address] => Șoseaua Colentina 2, București, Romania [end_location] => Array ( [lat] => 44.4521487 [lng] => 26.1267169 ) [start_address] => Strada Avrig 30, București, Romania [start_location] => Array ( [lat] => 44.4451446 [lng] => 26.1311305 ) [steps] => Array ( [0] => Array ( [distance] => Array ( [text] => 9 m [value] => 9 ) [duration] => Array ( [text] => 1 min [value] => 1 ) [end_location] => Array ( [lat] => 44.4450833 [lng] => 26.1312017 ) [html_instructions] => Head southeast on Strada Avrig [polyline] => Array ( [points] => cugnGqvn~CJM ) [start_location] => Array ( [lat] => 44.4451446 [lng] => 26.1311305 ) [travel_mode] => DRIVING ) [1] => Array ( [distance] => Array ( [text] => 0.2 km [value] => 209 ) [duration] => Array ( [text] => 1 min [value] => 45 ) [end_location] => Array ( [lat] => 44.4439255 [lng] => 26.1293794 ) [html_instructions] => Take the 1st right toward Șoseaua Mihai Bravu [polyline] => Array ( [points] => wtgnG_wn~CHCFAFAFAD#F#D#D#DBFH~#jCHRRj#BHZ`AJVPn# ) [start_location] => Array ( [lat] => 44.4450833 [lng] => 26.1312017 ) [travel_mode] => DRIVING ) [2] => Array ( [distance] => Array ( [text] => 0.7 km [value] => 733 ) [duration] => Array ( [text] => 1 min [value] => 66 ) [end_location] => Array ( [lat] => 44.4494197 [lng] => 26.1251047 ) [html_instructions] => Turn right onto Șoseaua Mihai Bravu [maneuver] => turn-right [polyline] => Array ( [points] => qmgnGskn~CNf#KPGL_#n#]j#m#|#e#h#[Za#b#eBrAqBxAIFk#Z_#R{#X{#RiA#mAX[FGBMDWHEBc#Pa#T]TUPEBgBfB ) [start_location] => Array ( [lat] => 44.4439255 [lng] => 26.1293794 ) [travel_mode] => DRIVING ) [3] => Array ( [distance] => Array ( [text] => 0.3 km [value] => 331 ) [duration] => Array ( [text] => 1 min [value] => 41 ) [end_location] => Array ( [lat] => 44.4521487 [lng] => 26.1267169 ) [html_instructions] => Turn right onto Șoseaua Colentina/DN2/E60/E85
Destination will be on the right
[maneuver] => turn-right [polyline] => Array ( [points] => {ohnG{pm~CYE[IoBk#oFeDYWYQq#[e#[ ) [start_location] => Array ( [lat] => 44.4494197 [lng] => 26.1251047 ) [travel_mode] => DRIVING ) ) [via_waypoint] => Array ( [0] => Array ( [location] => Array ( [lat] => 44.4445541 [lng] => 26.130791 ) [step_index] => 1 [step_interpolation] => 0.36662061075431 ) ) ) ) [overview_polyline] => Array ( [points] => cugnGqvn~CTQNCZBJDFH~#jC\~#^jA\fANf#KPg#|#kAhBaAdAa#b#eBrA{B`BkAn#wBl#iA#mAXc#Je#Ni#T_Aj#[TgBfBYEkCu#iG}DkAm#e#[ ) [summary] => Șoseaua Mihai Bravu and Șoseaua Colentina/DN2/E60/E85 [warnings] => Array ( ) [waypoint_order] => Array ( ) ) ) [status] => OK )

For finding the first value of routes, you can use below code :-
$json_a['routes'][0]['legs'][0]['distance']['text']
If you want to show all values then use foreach.
For sorting on values
function cmp($a, $b)
{
if ($a == $b) {
return 0;
}
return ($a < $b) ? -1 : 1;
}
$a = array(3, 2, 5, 6, 1);
usort($a, "cmp");
foreach ($a as $key => $value) {
echo "$key: $value\n";
}

Related

Show multiple api result photos on google map

Get 20 results of (example:School ) from google places api and i want to show photos on google map but some api results does not contain any image so how i can fix it. Error show: undefined index 'photos'.
if ($resp['status']=='OK') {
//Loop through get the multiple results
for ($i=0; $i < count($resp['results']) ; $i++) {
//Get the Important Data
$data['formatted_address'] = $resp['results'][$i]['formatted_address'];
$data['latitude'] = $resp['results'][$i]['geometry']['location']['lat'];
$data['longitude'] = $resp['results'][$i]['geometry']['location']
enter code here['lng'];
$data['icon'] = $resp['results'][$i]['icon'];
$data['name'] = $resp['results'][$i]['name'];
$data['height'] = $resp['results'][$i]['photos'][0]['height'];
$data['html_attributions'] = $resp['results'][$i]['photos'][0]
['html_attributions'][0];
$data['photo_reference'] = $resp['results'][$i]['photos'][0]
['photo_reference'];
$data['width'] = $resp['results'][$i]['photos'][0]['width'];
//Verify if Data Exist
if (!empty($data) && !empty ($data['latitude']) && !empty
($data['longitude'])) {
print_r($data);
}else{
echo "<h1 style=color:red;>Values Empty</h1>";
}
}//End for-loop
}else{
echo "<h1 style=color:red;>Status Error</h1>";
}
Get the result of schools from google places api the index[1] does not contain any image than how to show on map.
[results] => Array(
[0] => Array
(
[formatted_address] => Tariqabad Multan, Punjab, Pakistan
[geometry] => Array
(
[location] => Array
(
[lat] => 30.2073928
[lng] => 71.4530978
)
[viewport] => Array
(
[northeast] => Array
(
[lat] => 30.208742629893
[lng] => 71.454447629893
)
[southwest] => Array
(
[lat] => 30.206042970107
[lng] => 71.451747970107
)
)
)
[icon] =>
https://maps.gstatic.com/mapfiles/place_api/icons/school-71.png
[id] => de1405f04fffe5f2910789717344e513625aada3
[name] => Learner's Castle School Multan
[photos] => Array
(
[0] => Array
(
[height] => 730
[html_attributions] => Array
(
[0] => Faisal Mushtaq
)
[photo_reference] =>
CmRaAAAAvhDiC7bMqpf3F5lvLSUmDkv8aAqSF1AaC_EoeUhG
f40GCU3H0zaLOQZ96fRZxTJ9goxxh2C
CfJXtJyXfMOBBqPPsOAKenERrefpNwtdV07nDyPE62nSdz3aO7T1aQaMy
EhBQOTSeTEKvNxBCk5rxl7 FUGhQ9MSlemG_o0jxeYE9f0_RmtnQzrQ
[width] => 1296
)
)
[place_id] => ChIJqfKsD8IzOzkRomMlLG80aho
[plus_code] => Array
(
[compound_code] => 6F43+X6 Multan, Pakistan
[global_code] => 8J2H6F43+X6
)
[rating] => 5
[reference] => ChIJqfKsD8IzOzkRomMlLG80aho
[types] => Array
(
[0] => school
[1] => point_of_interest
[2] => establishment
)
)
[1] => Array
(
[formatted_address] => N Gulgasht Blvd, Basti Mehmood Kot,
Multan, Punjab 60000, Pakistan
[geometry] => Array
(
[location] => Array
(
[lat] => 30.2464553
[lng] => 71.483087
)
[viewport] => Array
(
[northeast] => Array
(
[lat] => 30.247805129893
[lng] => 71.484436829893
)
[southwest] => Array
(
[lat] => 30.245105470107
[lng] => 71.481737170107
)
)
)
[icon] =>
https://maps.gstatic.com/mapfiles/place_api/icons/school-71.png
[id] => 8648cd48c320f11b001a0eece814bd72abc07231
[name] => Zakariya Public School
[opening_hours] => Array
(
[open_now] => 1
)
[place_id] => ChIJ5c1N-YM0OzkRKKtxXEhilow
[plus_code] => Array
(
[compound_code] => 6FWM+H6 Multan, Pakistan
[global_code] => 8J2H6FWM+H6
)
[rating] => 4.4
[reference] => ChIJ5c1N-YM0OzkRKKtxXEhilow
[types] => Array
(
[0] => school
[1] => point_of_interest
[2] => establishment
)
)
[2] => Array
(
[formatted_address] => 17- Officers Colony, Officers Colony,
Multan, Punjab, Pakistan
[geometry] => Array
(
[location] => Array
(
[lat] => 30.2105142
[lng] => 71.4726681
)
[viewport] => Array
(
[northeast] => Array
(
[lat] => 30.211864029893
[lng] => 71.474017929893
)
[southwest] => Array
(
[lat] => 30.209164370107
[lng] => 71.471318270107
)
)
)
[icon] =>
https://maps.gstatic.com/mapfiles/place_api/icons/school-71.png
[id] => 8c809b4c5a4b8355899ddf6b6a7497bb8cb43be1
[name] => Jinnah Highs School System
[opening_hours] => Array
(
[open_now] => 1
)
[photos] => Array
(
[0] => Array
(
[height] => 1920
[html_attributions] => Array
(
[0] => A Google User
)
[photo_reference] =>
CmRZAAAAmQ8VIRfu9_s5UTrmBRwHpPWYuPjXWWcRj5KnWGwTy4yXo-
h2bWa8NSXrYSI8ukYD8nhfQRVxjxVKfWMxJlC4Xn8D9KBmoB7M9P
CZU5_XHvZ2heWSXPkqcGvjlcDiMalsEhA3VzcWjoDnL9Fs7Bs8PP
t4GhSePGS5CmCg0AXA8kEfl91iWotZgA
[width] => 2560
)
)
[place_id] => ChIJz4eKo_YzOzkRHvCbt43xkq8
[plus_code] => Array
(
[compound_code] => 6F6F+63 Multan, Pakistan
[global_code] => 8J2H6F6F+63
)
[rating] => 4.3
[reference] => ChIJz4eKo_YzOzkRHvCbt43xkq8
[types] => Array
(
[0] => school
[1] => point_of_interest
[2] => establishment
)
)
you should first check if photo key is exist in $resp['results'][$i] array by using isset function in php
for example
if(isset($resp['results'][$i]['photos']) && count($resp['results'][$i]['photos']) > 0)
{
// write your code
}
and also you should use phpenter code here count function to check $resp['results'][$i]['photos'] array has multi entry
so you can write $resp['results'][$i]['photos'][0] without have out of scope error

getting array value from json array PHP

i am using google place json array
json array
i am using this code to get name of place
$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]));
but the result always { 1 } where the result should be Biaggio Cafe
here if i print out the array 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 )
Checking at the structure of the json got from the call, to access the value you want to need to do like this.
$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']));
Results is an array, and you want to access to its first element ([0]). From that first element you want to get the property name. And all the properties on the element are set inside an array, so you need to access it by the property name.
You were using the object operator (->) to access elements from an array, that's why it didn't work.
echo print_r(....); is in a way redundant. print_r it self prints result to output in similar way as echo and returns TRUE which is what you are printing.
From documentation:
mixed print_r ( mixed $expression [, bool $return = false ] )
When the return parameter is TRUE, this function will return a string. Otherwise, the return value is TRUE.
Either do not use echo or set the return param to TRUE.
echo print_r($array, true);

ElasticSearch - order by score and location

I use elasticsearch. I need to find the results by word and sort them by deception (_score), and then by distance (_geo_distance)
By coincidence of phrases, I find the following sensations and sort them out by coincidence (_score).
Array
(
[took] => 23
[timed_out] =>
[_shards] => Array
(
[total] => 5
[successful] => 5
[failed] => 0
)
[hits] => Array
(
[total] => 469
[max_score] => 5.350864
[hits] => Array
(
[0] => Array
(
[_index] => salon
[_type] => services
[_id] => 7686
[_score] => 5.350864
[_source] => Array
(
[service_name] => Found a string 1
[service_id] => 10493
[location] => Array
(
[lat] => 55.701328
[lon] => 37.507412
)
)
)
[1] => Array
(
[_index] => salon
[_type] => services
[_id] => 8350
[_score] => 5.350864
[_source] => Array
(
[service_name] => Found a string 2
[service_id] => 11171
[location] => Array
(
[lat] => 55.869915
[lon] => 37.613728
)
)
)
[2] => Array
(
[_index] => salon
[_type] => services
[_id] => 14883
[_score] => 5.237593
[_source] => Array
(
[service_name] => Found a string 3
[service_id] => 17851
[location] => Array
(
[lat] => 55.691734
[lon] => 37.728164
)
)
)
...
But I do not understand how to add more and sorting by coordinates, for example, so that would be sorted by the nearest to 55.69,37.72
Here is my search code in elasticsearch:
require 'vendor/autoload.php';
function searchES($word) {
$client = \Elasticsearch\ClientBuilder::create()->setHosts([ES_HOST])->build();
$IDs = [];
$params = [];
$params['index'] = ES_INDEX;
if ($client->indices()->exists($params)) {
$params['type'] = ES_TYPE;
$params['size'] = 10000;
$params['body']['sort'] = ['_score' => 'desc'];
$params['body']['query']['match']['service_name'] = trim($word);
$result = $client->search($params);
if ($result['hits']['total'] > 0) {
$result = $result['hits']['hits'];
foreach ($result as $val) {
$k = $val['_source']['service_id'];
$IDs[$k] = $val['_source']['service_name'];
}
}
}
return $IDs;
}
Params:
Array
(
[index] => salon
[body] => Array
(
[settings] => Array
(
[analysis] => Array
(
[filter] => Array
(
[ru_stop] => Array
(
[type] => stop
[stopwords] => _russian_
)
[ru_stemmer] => Array
(
[type] => stemmer
[language] => russian
)
)
[analyzer] => Array
(
[default] => Array
(
[tokenizer] => standard
[filter] => Array
(
[0] => lowercase
[1] => ru_stop
[2] => ru_stemmer
)
)
)
)
)
[mappings] => Array
(
[_default_] => Array
(
[properties] => Array
(
[service_name] => Array
(
[type] => string
[analyzer] => default
)
)
)
)
)
)

How to sort object array by value deep inside array

I have this array:
stdClass Object
(
[tid] => 26001835
[vid] => 5
[name] => AppleTV
[description] => My description
[format] => filtered_html
[weight] => 0
[vocabulary_machine_name] => how_to_watch_device
[field_device_image] => Array
(
[und] => Array
(
[0] => Array
(
[fid] => 26608990
[alt] =>
[title] =>
[width] => 194
[height] => 102
[uid] => 26000697
[filename] => Apple-TV.png
[uri] => public://Apple-TV.png
[filemime] => image/png
[filesize] => 2103
[status] => 1
[timestamp] => 1405346182
)
)
)
[field_buy_now_button_link] => Array
(
[und] => Array
(
[0] => Array
(
[value] => http://www.something.com
[format] =>
[safe_value] => http://www.something.com
)
)
)
[field_learn_more] => Array
(
[und] => Array
(
[0] => Array
(
[value] => http://something.com/somepage
[format] =>
[safe_value] => http://something.com/somepage
)
)
)
[field_device_category] => Array
(
[und] => Array
(
[0] => Array
(
[value] => network
)
)
)
)
stdClass Object
(
[tid] => 26001834
[vid] => 5
[name] => Playstation - USA
[description] => My description
[format] => filtered_html
[weight] => 2
[vocabulary_machine_name] => how_to_watch_device
[field_device_image] => Array
(
[und] => Array
(
[0] => Array
(
[fid] => 26608991
[alt] =>
[title] =>
[width] => 194
[height] => 102
[uid] => 26000697
[filename] => ps4network.png
[uri] => public://ps4network.png
[filemime] => image/png
[filesize] => 4566
[status] => 1
[timestamp] => 1405346218
)
)
)
[field_buy_now_button_link] => Array
(
[und] => Array
(
[0] => Array
(
[value] => http://www.somesite.com
[format] =>
[safe_value] => http://somesite.com
)
)
)
[field_learn_more] => Array
(
)
[field_device_category] => Array
(
[und] => Array
(
[0] => Array
(
[value] => blast_areas
)
)
)
)
stdClass Object
(
[tid] => 26001836
[vid] => 5
[name] => Brighthouse Networks
[description] => My description
[format] => filtered_html
[weight] => 3
[vocabulary_machine_name] => how_to_watch_device
[field_device_image] => Array
(
[und] => Array
(
[0] => Array
(
[fid] => 26608993
[alt] =>
[title] =>
[width] => 194
[height] => 102
[uid] => 26000697
[filename] => brighthouse.png
[uri] => public://brighthouse.png
[filemime] => image/png
[filesize] => 8392
[status] => 1
[timestamp] => 1405358781
)
)
)
[field_buy_now_button_link] => Array
(
)
[field_learn_more] => Array
(
)
[field_device_category] => Array
(
[und] => Array
(
[0] => Array
(
[value] => ppv_provider
)
)
)
)
I want to sort the array by the array by the value in field_device_category. Basically, I want to group the results but first I need to make sure all the objects are sorted by field_device_category.
Thanks in advance!
Use usort for this kind of sorting. It uses Quicksort in the background and takes a user-defined function to compare the array elements:
usort($array, "complicatedArrayComparer");
function complicatedArrayComparer($a,$b)
{
if ($a['field_device_category'] == $b['field_device_category']) {
return 0;
}
return ($a['field_device_category'] < $b['field_device_category']) ? -1 : 1;
}

How to get the Multidimensional array value in foreach loop using php [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question appears to be off-topic because it lacks sufficient information to diagnose the problem. Describe your problem in more detail or include a minimal example in the question itself.
Closed 9 years ago.
Improve this question
This my code ..... I need output of hotel name, id, selling price etc
array value will be loop because I have get result in bulk manner .
Array
(
[TestMode] => true
[HotelAvailability] => Array
(
[0] => Array
(
[Hotel] => Array
(
[Id] => 3027405
[Name] => Royal Plaza
[Region] => Array
(
[Id] => 16849
[Name] => Chennai (Madras)
)
[Type] => Hotel
[Stars] => 3
[Rank] => 1
)
[Result] => Array
(
[QuoteId] => 12249136-10
[Room] => Array
(
[RoomType] => Array
(
[Code] => 1002196
[Text] => Double Standard
)
[MealType] => Array
(
[Code] => 1000018
[Text] => Bed and breakfast
)
[SellingPrice] => Array
(
[Currency] => INR
[Amount] => 1824.26
[Estimated] => false
[Converted] => false
)
[Guests] => Array
(
[Adult] => Array
(
[0] => Array
(
[Id] => -252645204
[Forename] => Array
(
)
[Surname] => Array
(
)
[SellingPrice] => Array
(
[Currency] => INR
[Amount] => 912.13
[Estimated] => false
[Converted] => false
)
)
[1] => Array
(
[Id] => -252645205
[Forename] => Array
(
)
[Surname] => Array
(
)
[SellingPrice] => Array
(
[Currency] => INR
[Amount] => 912.13
[Estimated] => false
[Converted] => false
)
)
)
)
[Confirmation] => allocation
)
)
)
[1] => Array
(
[Hotel] => Array
(
[Id] => 2118726
[Name] => Days Inn Deccan Plaza
[Region] => Array
(
[Id] => 16849
[Name] => Chennai (Madras)
)
[Type] => Hotel
[Stars] => 3
[Rank] => 1
)
[Result] => Array
(
[QuoteId] => 12249136-36
[Room] => Array
(
[RoomType] => Array
(
[Code] => 1002196
[Text] => Double Standard
)
[MealType] => Array
(
[Code] => 1000018
[Text] => Bed and breakfast
)
[SellingPrice] => Array
(
[Currency] => INR
[Amount] => 3192.90
[Estimated] => false
[Converted] => false
)
[Guests] => Array
(
[Adult] => Array
(
[0] => Array
(
[Id] => -252645292
[Forename] => Array
(
)
[Surname] => Array
(
)
[SellingPrice] => Array
(
[Currency] => INR
[Amount] => 1596.45
[Estimated] => false
[Converted] => false
)
)
[1] => Array
(
[Id] => -252645293
[Forename] => Array
(
)
[Surname] => Array
(
)
[SellingPrice] => Array
(
[Currency] => INR
[Amount] => 1596.45
[Estimated] => false
[Converted] => false
)
)
)
)
[Confirmation] => allocation
)
)
)
[2] => Array
(
[Hotel] => Array
(
[Id] => 723729
[Name] => Green Park
[Region] => Array
(
[Id] => 16849
[Name] => Chennai (Madras)
)
[Type] => Hotel
[Stars] => 4
[Rank] => 1
)
[Result] => Array
(
[0] => Array
(
[QuoteId] => 12249136-33
[Room] => Array
(
[RoomType] => Array
(
[Code] => 1004527
[Text] => Double Or Twin Deluxe
)
[MealType] => Array
(
[Code] => 1000018
[Text] => Bed and breakfast
)
[SellingPrice] => Array
(
[Currency] => INR
[Amount] => 3273.82
[Estimated] => false
[Converted] => false
)
[Guests] => Array
(
[Adult] => Array
(
[0] => Array
(
[Id] => -252645286
[Forename] => Array
(
)
[Surname] => Array
(
)
[SellingPrice] => Array
(
[Currency] => INR
[Amount] => 1636.91
[Estimated] => false
[Converted] => false
)
)
[1] => Array
(
[Id] => -252645287
[Forename] => Array
(
)
[Surname] => Array
(
)
[SellingPrice] => Array
(
[Currency] => INR
[Amount] => 1636.91
[Estimated] => false
[Converted] => false
)
)
)
)
[Confirmation] => allocation
)
)
[1] => Array
(
[QuoteId] => 12249136-34
[Room] => Array
(
[RoomType] => Array
(
[Code] => 2062742
[Text] => Double or Twin BUSINESS-CLUB
)
[MealType] => Array
(
[Code] => 1000018
[Text] => Bed and breakfast
)
[SellingPrice] => Array
(
[Currency] => INR
[Amount] => 3863.18
[Estimated] => false
[Converted] => false
)
[Guests] => Array
(
[Adult] => Array
(
[0] => Array
(
[Id] => -252645288
[Forename] => Array
(
)
[Surname] => Array
(
)
[SellingPrice] => Array
(
[Currency] => INR
[Amount] => 1931.59
[Estimated] => false
[Converted] => false
)
)
[1] => Array
(
[Id] => -252645289
[Forename] => Array
(
)
[Surname] => Array
(
)
[SellingPrice] => Array
(
[Currency] => INR
[Amount] => 1931.59
[Estimated] => false
[Converted] => false
)
)
)
)
[Confirmation] => allocation
)
)
)
)
If I understood your question correctly, you would like to extract the Hotel Id, Name, and SellingPrice keys from this array, in a loop.
If we assume the above array is stored in a variable called $HotelData, and that the array structure is consistent with the above output in your question, then the following code should allow you to do what you want...
foreach($HotelData['HotelAvailability'] as $hotel) {
$id = $hotel['Hotel']['Id'];
$name = $hotel['Hotel']['Name'];
$price = $hotel['Result']['Room']['SellingPrice']['Currency'] . ' ' . $hotel['Result']['Room']['SellingPrice']['Amount'] ;
echo "$id - $name: $price<br>\n";
}
/* This should output something like
*
* 3027405 - Royal Plaza: INR 1824.26
* 2118726 - Days Inn Deccan Plaza - INR 3192.90
* ...
*/
foreach($data['HotelAvailability'] AS $record) {
echo 'Id: '; echo $record['Hotel']['Id'];
echo '<br />';
echo 'Name: '; echo $record['Hotel']['Name'];
echo '-------------'; echo '<br />';
}

Categories