title: How to loop through array of objects in PHP
body: <p>I'm very new to PHP and I need your help! 
  I need to write backend for my app that receives json post and write data to json file. And I'm stuck with looping through array.</p>
  
  <pre><code>$postData = file_get_contents("php://input");
  $request = json_decode($postData);
  var_damp($request)
  </code></pre>
  
  <p>shows array:</p>
  
  <pre><code>array(2) {
    [0]=&gt;
    object(stdClass)#1 (8) {
      ["name"]=&gt;
      string(11) "Alex Jordan"
      ["email"]=&gt;
      string(14) "alex@gmail.com"
      ["phone"]=&gt;
      int(123456789)
      ["street"]=&gt;
      string(12) "street, str."
      ["city"]=&gt;
      string(7) "Chicago"
      ["state"]=&gt;
      string(7) "Chicago"
      ["zip"]=&gt;
      string(5) "07202"
      ["$$hashKey"]=&gt;
      string(8) "object:3"
    }
    [1]=&gt;
    object(stdClass)#2 (8) {
      ["name"]=&gt;
      string(15) "Michael Jonhson"
      ["email"]=&gt;
      string(17) "michael@gmail.com"
      ["phone"]=&gt;
      float(11987654321)
      ["street"]=&gt;
      string(12) "street, str."
      ["city"]=&gt;
      string(11) "Los Angeles"
     ["state"]=&gt;
     string(10) "California"
     ["zip"]=&gt;
     string(5) "27222"
     ["$$hashKey"]=&gt;
     string(8) "object:4"
   }
  }
  </code></pre>
  
  <p>I'm trying to loop through the objects and getting error </p>
  
  <p><code>Object of class stdClass could not be converted to string</code></p>
  
  <p>Here is how I'm trying to do it:</p>
  
  <pre><code>    foreach($request as $i =&gt; $i_value) {
          echo $i_value;
      }
  </code></pre>