title: Pushing values into multidimensional array with PHP
body: <p>I'm using CakePHP and retrieve user info, make a calculation, and then I'd like to add that calculation into the array per user</p>
  
  <p>After looking up a user, this is the structure of the array</p>
  
  <pre><code>print_r($user_info);
  
  Array
  (
      [0] =&gt; Array
          (
              [User] =&gt; Array
                  (
                      [id] =&gt; 1
                      [email] =&gt; admin@gmail.com
                      [website] =&gt; www.admin.com
  
                  )
  
          )
  
  )
  </code></pre>
  
  <p>Now I'm trying to add a 'num_payments' key for this particular user in a loop</p>
  
  <pre><code>array_push($user_info[$i]['User'],array('num_payments' =&gt; $customer_payments[$i]['num_payments']));
  </code></pre>
  
  <p>Here's the resulting array</p>
  
  <pre><code>Array
  (
      [0] =&gt; Array
          (
              [User] =&gt; Array
                  (
                      [id] =&gt; 1
                      [email] =&gt; admin@gmail.com
                      [website] =&gt; www.admin.com
                      [0] =&gt; Array
                          (
                              [num_payments] =&gt; 1
                          )
  
                  )
  
          )
  
  )
  </code></pre>
  
  <p>How can I get it into this structure?</p>
  
  <pre><code>Array
  (
      [0] =&gt; Array
          (
              [User] =&gt; Array
                  (
                      [id] =&gt; 1
                      [email] =&gt; admin@gmail.com
                      [website] =&gt; www.admin.com
                      [num_payments] =&gt; 1
                  )
  
          )
  
  )
  </code></pre>