title: php get array values from stdClass object
body: <p>Here is my function which collects data from page. Data is stored into array and at the end I echo it using var_dump().</p>
  
  <p>Data is bunched into array of length 40. I was trying to get each array value seperatelly.</p>
  
  <p>Array result looks like this when I dump using <code>var_dump($root)</code> :</p>
  
  <pre><code>object(stdClass)[1]
    public 'items' =&gt; 
      array (size=40)
        0 =&gt; 
          object(stdClass)[12983]
            public 'comment' =&gt; string 'Locanda is great ! Maybe a bit overrated... But I definitely enjoyed my first dinner here! &lt;br&gt;&lt;br&gt;Trippa alla romana is so good! My first time eating tripe and the texture wasn&amp;#39;t bad at all plus the sauce was fantastic! &lt;br&gt;&lt;br&gt;The leg of lamb was nice, a bit too rare for me but I didn&amp;#39;t specify how I wanted it so next time I will. &lt;br&gt;&lt;br&gt;The hen wrapped in pancetta was so delicious and juicy! Would recommend that over the lamb. &lt;br&gt;&lt;br&gt;We also had a nice pasta dish.. Orecchiette which was of cour'... (length=738)
            public 'rating' =&gt; string '4.0' (length=3)
            public 'date' =&gt; string '2014-04-03' (length=10)
        1 =&gt; 
          object(stdClass)[12984]
            public 'comment' =&gt; string 'Made reservations last friday night here for a fun special dinner, had a pretty good time but was a bit underwhelmed.&lt;br&gt;&lt;br&gt;We arrived early for our reservation, about 15 minutes and were going to go to the bar for a cocktail but the hostess told us that she could sit us early and to not to go to the bar and then we were sat 10 minutes after our reservation time. A bit annoying but I get it, it&amp;#39;s Friday night. We got a great table in the back half or the restaurant so we weren&amp;#39;t by the door and awk'... (length=1676)
            public 'rating' =&gt; string '3.0' (length=3)
            public 'date' =&gt; string '2014-04-21' (length=10)
        2 =&gt; 
          object(stdClass)[12985]
            public 'comment' =&gt; string 'Thinking to have something special for dinner on Sunday, we ordered takeout from Locanda through Postmates. Â Words cannot describe how sad we were when the food came. Â The portions are TINY TINY TINY and slopped into large paper takeout containers (no, not even the wax lined ones) that make them look even smaller. Â Miniscule, beyond small portions. Â The sauce soaked into the containers, so icky. Â Food has never looked so pitiful.&lt;br&gt;&lt;br&gt;We paid $70 for three dishes that would all fit on a single plate '... (length=2081)
            public 'rating' =&gt; string '2.0' (length=3)
            public 'date' =&gt; string '2014-03-31' (length=10)
        3 =&gt; 
          object(stdClass)[12986]
            public 'comment' =&gt; string 'I can&amp;#39;t say enough good things about locanda. Finally reviewing after eating dinner there as opposed to just visiting the bar. &lt;br&gt;&lt;br&gt;Dinner was fantastic - warm bread and brussel sprouts to start. Pasta with broccoli rabe and sausage was so wonderful (and so hard to find in sf!)&lt;br&gt;&lt;br&gt;Now for the bar. Bartenders are so knowledgeable and friendly. Â I love how they&amp;#39;ll listen to your feedback and then get creative on your next drink. Most recently tried the steam shandy - excellent! Â Oh, and old f'... (length=530)
            public 'rating' =&gt; string '5.0' (length=3)
            public 'date' =&gt; string '2014-03-30' (length=10)
        4 =&gt; 
          object(stdClass)[12987]
            public 'comment' =&gt; string 'The wait for 2 on a Saturday night at 6:15pm was only 20 minutes. Cocktails were delicious, though the ginger cocktail was too gingery. We got the whole grilled fish. It was pretty good but a bit too salty. The atmosphere is great.' (length=231)
            public 'rating' =&gt; string '4.0' (length=3)
            public 'date' =&gt; string '2014-04-20' (length=10)
  </code></pre>
  
  <p>and so on</p>
  
  <p>the code which give this result.</p>
  
  <pre><code>  function Getdata($url){
      print("$url\n");
      $root = new stdClass();
      $items = array();
      $html = file_get_html($url);
      if($html){
        $containers = $html-&gt;find('div.review-list div.review div.review-wrapper');
        foreach($containers as $container){
          $comments = $container-&gt;find('div.review-content p.review_comment');
          $item = new stdClass();
          foreach($comments as $comment){
            $comment_html = $comment-&gt;innertext();
            $item-&gt;comment = $comment_html;
          }
          $metas = $container-&gt;find('div.review-content meta');
          foreach($metas as $meta){
            $itemprop = $meta-&gt;itemprop;
            $content = $meta-&gt;content;
            if($itemprop == 'ratingValue') $key = 'rating';
            else $key = 'date';
            $item-&gt;$key = $content;
          }
          $items[] = $item;
        }
      }
      $root-&gt;items = $items;
      if($html){
        $html-&gt;clear();
        unset($html);
      }
      var_dump $root;
  
    }
  </code></pre>
  
  <p>Here I tried to get each of the <code>comment</code>, <code>rating</code>, <code>date</code> separately </p>
  
  <pre><code>  for($i = 0 ; $i &lt;=80 ; $i = $i + 40)
      {
            $url = 'http://www.testioco.com/biz?start='.$i.'';
            $root = yelp($url);
              for($j = 0; $j &lt; sizeof($root); $j++)
                  {
                      echo $root[$j]['comment']."&lt;br/&gt;";                  
                      echo $root[$j]['rating']."&lt;br/&gt;";               
                      echo $root[$j]['date']."&lt;br/&gt;";             
                  }
            //var_dump($root);
            flush();
            ob_flush();
      }
  </code></pre>
  
  <p>I want to get each comment, rate, date separate to store in db. so please help me accordingly.</p>