title: PHP: Count number of objects within another object?
body: <p>I'm still new at PHP and I can't seem to count the number of Objects within another object. The stdClass object looks like this:</p>
  
  <pre><code>stdClass Object (
  
  [data] =&gt; Array (
      [0] =&gt; stdClass Object (
          [Code] =&gt; ABC
          [Title] =&gt; Alphabet
          [sections] =&gt; Array (
              [0] =&gt; stdClass Object (
                  [Name] =&gt; Sounds
                  [sections] =&gt; Vowels
              )
          )
      )
  
  )
  </code></pre>
  
  <p>I must count the number of elements in this object so i can echo it properly. For the data, I was able to do it:</p>
  
  <pre><code>$number = count($hanap-&gt;data);
  </code></pre>
  
  <p>I don't know how to do it for the sections.</p>
  
  <pre><code>$number = count($hanap-&gt;data-&gt;sections); // does not work.
  </code></pre>
  
  <p>Thanks. Any help will be greatly appreciated. :)</p>