title: Json php parsing zomato
body: <p>I am using zomato api to get a json output which is working via php however I want to print out few arrays out of all the data that I am getting and I am having difficulty with that. Can some one help please. This is the output I am getting</p>
  
  <pre><code>Array
  (
      [R] =&gt; Array
          (
              [res_id] =&gt; 18559961
          )
  
      [apikey] =&gt; 123
      [id] =&gt; 18559961
      [name] =&gt; Between Buns
      [url] =&gt; https://www.zomato.com/ncr/between-buns-sda-new-delhi?utm_source=api_basic_user&amp;utm_medium=api&amp;utm_campaign=v2.1
      [location] =&gt; Array
          (
              [address] =&gt; C13, SDA Market, Opposite IIT Delhi, SDA, New Delhi
              [locality] =&gt; SDA Market, SDA
              [city] =&gt; New Delhi
              [city_id] =&gt; 1
              [latitude] =&gt; 28.5465059222
              [longitude] =&gt; 77.1969081089
              [zipcode] =&gt; 
              [country_id] =&gt; 1
              [locality_verbose] =&gt; SDA Market, SDA, New Delhi
          )
  
      [switch_to_order_menu] =&gt; 0
      [cuisines] =&gt; Burger, American, Desserts, Sandwich, Salad, European
      [average_cost_for_two] =&gt; 1500
      [price_range] =&gt; 3
      [currency] =&gt; Rs.
      [offers] =&gt; Array
          (
          )
  
      [opentable_support] =&gt; 0
      [is_zomato_book_res] =&gt; 0
      [mezzo_provider] =&gt; OTHER
      [is_book_form_web_view] =&gt; 0
      [book_form_web_view_url] =&gt; 
      [book_again_url] =&gt; 
      [thumb] =&gt; https://b.zmtcdn.com/data/pictures/chains/1/18559961/c0e491e63d2e95c0c3049de0e8bbb05c.jpg?fit=around%7C200%3A200&amp;crop=200%3A200%3B%2A%2C%2A
      [user_rating] =&gt; Array
          (
              [aggregate_rating] =&gt; 4.0
              [rating_text] =&gt; Very Good
              [rating_color] =&gt; 5BA829
              [votes] =&gt; 723
          )
  
      [photos_url] =&gt; https://www.zomato.com/ncr/between-buns-sda-new-delhi/photos?utm_source=api_basic_user&amp;utm_medium=api&amp;utm_campaign=v2.1#tabtop
      [menu_url] =&gt; https://www.zomato.com/ncr/between-buns-sda-new-delhi/menu?utm_source=api_basic_user&amp;utm_medium=api&amp;utm_campaign=v2.1&amp;openSwipeBox=menu&amp;showMinimal=1#tabtop
      [featured_image] =&gt; https://b.zmtcdn.com/data/pictures/chains/1/18559961/c0e491e63d2e95c0c3049de0e8bbb05c.jpg?output-format=webp
      [medio_provider] =&gt; 1
      [has_online_delivery] =&gt; 0
      [is_delivering_now] =&gt; 0
      [include_bogo_offers] =&gt; 1
      [deeplink] =&gt; zomato://restaurant/18559961
      [is_table_reservation_supported] =&gt; 1
      [has_table_booking] =&gt; 1
      [book_url] =&gt; https://www.zomato.com/ncr/between-buns-sda-new-delhi/book?utm_source=api_basic_user&amp;utm_medium=api&amp;utm_campaign=v2.1
      [events_url] =&gt; https://www.zomato.com/ncr/between-buns-sda-new-delhi/events#tabtop?utm_source=api_basic_user&amp;utm_medium=api&amp;utm_campaign=v2.1
  )
  </code></pre>
  
  <p>and this is my code </p>
  
  <pre><code>&lt;?php 
  
  // Errors on
  error_reporting(E_ALL);
  
  // Get cURL resource
  $curl = curl_init();
  
  // Curl options
  curl_setopt_array($curl, array(
      CURLOPT_RETURNTRANSFER =&gt; true,
      CURLOPT_HTTPHEADER =&gt; ['Accept: application/json', 'user-key: 123'],
      CURLOPT_URL =&gt; 'https://developers.zomato.com/api/v2.1/restaurant?res_id=123',
  ));
  
  // Send the request &amp; save response to $resp
  $resp = curl_exec($curl);
  
  // Check for errors if curl_exec fails
  if(!curl_exec($curl)){
      die('Error: "' . curl_error($curl) . '" - Code: ' . curl_errno($curl));
  }
  
  // Close request to clear up some resources
  curl_close($curl);
  
  // dumping $resp
  //echo 'var_dump: &lt;br&gt;';
  //var_dump($resp);
  //echo '&lt;br&gt;&lt;br&gt;';
  
  // Decode json
  $jsonZomato = json_decode($resp,true);
  
  // print readable results
  print "&lt;pre&gt;";
  print_r($jsonZomato);
  print "&lt;/pre&gt;";
  print $jsonZomato-&gt;aggregate_rating;//this is the problem
  
  ?&gt;
  </code></pre>
  
  <p>The error I am getting is Notice: Trying to get property of non-object in /home/betweenbuns/public_html/rating_2.php on line 45</p>