title: php cakephp: how to count elements of a nested array
body: <p>How to count elements of a nested array? I want to count elements of $student_info['Aptitude']. </p>
  
  <p>I tried the following and I'm getting undefined index at the following code:</p>
  
  <pre><code>else if (count($student_info["Aptitude"])==0){ //no records for report card
           $this-&gt;Session-&gt;setFlash('Your child is a new student in our school. 
              He/She doesn\'t have records for a report card yet.');
              $this-&gt;redirect(array('controller'=&gt;'pages','action'=&gt;'home'));
  </code></pre>
  
  <p>Aptitude is an array within $student_info which has 4 arrays </p>
  
  <p>var_dump($student_info) produces the following output. Aptitude array is on the last line. It doesn't have any elements:</p>
  
  <pre><code>array(1) { 
      [0]=&gt; array(4) { 
          ["Student"]=&gt; array(10) { 
              ["id"]=&gt; string(2) "20" 
              ["name"]=&gt; string(15) "Uma Palaniappan" 
              ["gender"]=&gt; string(6) "Female" 
              ["dob"]=&gt; string(10) "2007-04-26" 
              ["created"]=&gt; string(19) "2011-12-29 10:14:03" 
              ["modified"]=&gt; string(19) "2011-12-29 10:14:03" 
              ["merry_class_id"]=&gt; string(1) "3" 
              ["merry_parent_id"]=&gt; string(2) "25" 
              ["term1_comments"]=&gt; NULL
              ["term2_comments"]=&gt; NULL 
          } 
          ["MerryParent"]=&gt; array(14) { 
              ["id"]=&gt; string(2) "25" 
              ["initial"]=&gt; string(2) "Mr" 
              ["name"]=&gt; string(13) "Palaniappan K" 
              ["username"]=&gt; string(7) "kpalani" 
              ["email"]=&gt;string(20) "kpalani@streamyx.com" 
              ["password"]=&gt; string(40) "43f5e1298f3b2478a9cd4ab7c6f5f703380dbcc9" 
              ["landline"]=&gt; string(12) "044-77223399" 
              ["mobile"]=&gt; string(10) "9860662309" 
              ["address"]=&gt; string(15) "44 Megala Chowk" 
              ["state_id"]=&gt; string(1) "6" 
              ["city_id"]=&gt; string(3) "103" 
              ["postal_code"]=&gt; string(6) "384733" 
              ["created"]=&gt; string(19) "2011-12-29 10:14:03" 
              ["modified"]=&gt; string(19) "2011-12-29 10:52:23" 
          } 
  
          ["MerryClass"]=&gt; array(2) { 
              ["id"]=&gt; string(1) "3" 
              ["class_name"]=&gt; string(3) "LKG" 
          } 
          ["Aptitude"]=&gt; array(0) { 
          } 
      } 
  } 
  </code></pre>
  
  <p>thank you.</p>