title: PHP Loop stdClass Object
body: <p>I have a call to a webservice which is returning json data. I use:</p>
  
  <pre><code>$response_json = json_decode ( $response );
  </code></pre>
  
  <p>If I print_r($response) I get this:</p>
  
  <pre><code>stdClass Object
  (
      [meta] =&gt; stdClass Object
      (
          [no_of_pages] =&gt; 3
          [current_page] =&gt; 1
          [max_items_per_page] =&gt; 250
          [no_of_items] =&gt; 740
      )
  
  [data] =&gt; Array
      (
          [0] =&gt; stdClass Object
              (
                  [orderid] =&gt; 322191645
                  [customer] =&gt; stdClass Object
                      (
                          [city] =&gt; FELIXSTOWE
  </code></pre>
  
  <p>I am trying to loop through the orders:</p>
  
  <pre><code>foreach($response_json as $orders) {
      echo $orders.['data'].[0].['orderid'];
      }
  </code></pre>
  
  <p>but I keep getting:</p>
  
  <p>Catchable fatal error: Object of class stdClass could not be converted to string. I have also tried many other ways, but I just can't seem to access the data in a loop. Thanks in advance.</p>