title: Renaming the keys in multidimensional associate arrays
body: <p>I have searched SO and Google and have found lots of similar questions, but nothing that fits my exact use case.</p>
  
  <p>I have an array of arrays like this:</p>
  
  <pre><code>Array
  (
      [0] =&gt; Array
          (
              [id] =&gt; c80c5133-1140-8187-ad3b-524b4ed0f1a8
              [date_entered] =&gt; 10/01/2013 03:38pm
          )
  
      [1] =&gt; Array
          (
              [id] =&gt; 176815c6-b57f-7643-0f08-524b4f22b51c
              [date_entered] =&gt; 10/01/2013 03:42pm
          )
  
      [2] =&gt; Array
          (
              [id] =&gt; df0f8824-0b12-b92e-1d2e-524c6cb19c41
              [date_entered] =&gt; 10/02/2013 11:56am
          )
  
  )
  </code></pre>
  
  <p>I need to rename the keys of the first dimension to be the value of the date_entered key in the second dimension arrays like this so that I can (hopefully) sort the array by the most recent date.  I need to preserve the contents of each array because I will need to grab the ID that corresponds to the correct date.</p>
  
  <pre><code>Array
  (
      [10/01/2013 03:38pm] =&gt; Array
          (
              [id] =&gt; c80c5133-1140-8187-ad3b-524b4ed0f1a8
              [date_entered] =&gt; 10/01/2013 03:38pm
          )
  
      [10/01/2013 03:42pm] =&gt; Array
          (
              [id] =&gt; 176815c6-b57f-7643-0f08-524b4f22b51c
              [date_entered] =&gt; 10/01/2013 03:42pm
          )
  
      [10/02/2013 11:56am] =&gt; Array
          (
              [id] =&gt; df0f8824-0b12-b92e-1d2e-524c6cb19c41
              [date_entered] =&gt; 10/02/2013 11:56am
          )
  
  )
  </code></pre>
  
  <p>I am trying to do it like this (which is obviously not correct) but for the life of me I still can't get it.</p>
  
  <pre><code>foreach ($array as $key) {
      foreach ($key as $subkey =&gt; $subvalue) {
          if ($subkey == 'date_entered') {
              // change the name of the key?
          }
      }
  }
  </code></pre>
  
  <p>I am really struggling with multidimensional arrays and manipulating them, no matter how much I read and practice!  Can anyone help?</p>