title: PHP: Count a stdClass object
body: <p>I have a stdClass object created from json_decode that won't return the right number when I run the count($obj) function.  The object has 30 properties, but the return on the count() function is say 1.</p>
  
  <p>Any ideas?</p>
  
  <p>Below is an example of one of the objects.  (I'm requesting the daily trend information from Twitter).  If this object had more than one property, the count($obj) would equal 1.</p>
  
  <pre><code>[trends] =&gt; stdClass Object
      (
          [2009-08-21 11:05] =&gt; Array
              (
                  [0] =&gt; stdClass Object
                      (
                          [query] =&gt; "Follow Friday"
                          [name] =&gt; Follow Friday
                      )
  
                  [1] =&gt; stdClass Object
                      (
                          [query] =&gt; "Inglourious Basterds" OR "Inglorious Basterds"
                          [name] =&gt; Inglourious Basterds
                      )
  
                  [2] =&gt; stdClass Object
                      (
                          [query] =&gt; Inglourious
                          [name] =&gt; Inglourious
                      )
  
                  [3] =&gt; stdClass Object
                      (
                          [query] =&gt; #songsincode
                          [name] =&gt; #songsincode
                      )
  
                  [4] =&gt; stdClass Object
                      (
                          [query] =&gt; #shoutout
                          [name] =&gt; #shoutout
                      )
  
                  [5] =&gt; stdClass Object
                      (
                          [query] =&gt; "District 9"
                          [name] =&gt; District 9
                      )
  
                  [6] =&gt; stdClass Object
                      (
                          [query] =&gt; #howmanypeople
                          [name] =&gt; #howmanypeople
                      )
  
                  [7] =&gt; stdClass Object
                      (
                          [query] =&gt; Ashes OR #ashes
                          [name] =&gt; Ashes
                      )
  
                  [8] =&gt; stdClass Object
                      (
                          [query] =&gt; #youtubefail
                          [name] =&gt; #youtubefail
                      )
  
                  [9] =&gt; stdClass Object
                      (
                          [query] =&gt; TGIF
                          [name] =&gt; TGIF
                      )
  
                  [10] =&gt; stdClass Object
                      (
                          [query] =&gt; #wish09
                          [name] =&gt; #wish09
                      )
  
                  [11] =&gt; stdClass Object
                      (
                          [query] =&gt; #watch
                          [name] =&gt; #watch
                      )
  
                  [12] =&gt; stdClass Object
                      (
                          [query] =&gt; Avatar
                          [name] =&gt; Avatar
                      )
  
                  [13] =&gt; stdClass Object
                      (
                          [query] =&gt; Ramadhan
                          [name] =&gt; Ramadhan
                      )
  
                  [14] =&gt; stdClass Object
                      (
                          [query] =&gt; Goodnight
                          [name] =&gt; Goodnight
                      )
  
                  [15] =&gt; stdClass Object
                      (
                          [query] =&gt; iPhone
                          [name] =&gt; iPhone
                      )
  
                  [16] =&gt; stdClass Object
                      (
                          [query] =&gt; #iranelection
                          [name] =&gt; #iranelection
                      )
  
                  [17] =&gt; stdClass Object
                      (
                          [query] =&gt; Apple
                          [name] =&gt; Apple
                      )
  
                  [18] =&gt; stdClass Object
                      (
                          [query] =&gt; "Usain Bolt"
                          [name] =&gt; Usain Bolt
                      )
  
                  [19] =&gt; stdClass Object
                      (
                          [query] =&gt; H1N1
                          [name] =&gt; H1N1
                      )
  
              )
       )
  </code></pre>