I'm working with the google places api and I currently have a json of a list of restaurants and details of them near the users location. In my code I take this json and put it in a php array and in my javascript I'm trying to access each element inside of this array. I have the following code which should work but for some reason it isn't and I can't figure out why. I've searched other questions on this topic and none of them have helped me.
define("PLACES_API_ENDPOINT", "https://maps.googleapis.com/maps/api/place/textsearch/json?query=restaraunts+near".$address);
$curl1 = curl_init();
curl_setopt($curl1, CURLOPT_URL, PLACES_API_ENDPOINT . "&key=mykey");
curl_setopt($curl1, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl1, CURLOPT_SSL_VERIFYPEER, false);
$response = curl_exec($curl1);
/*echo "<hr>";*/
//var_dump($response);
$response = json_decode($response, true);
<script>
window.onload=function(){
console.log("<?php echo $response['results'] ?>");
};
</script>