title: Change $key of associative array in a foreach loop in php
body: <p>I have an array like this:</p>
  
  <pre><code>array(
      'firstName' =&gt; 'Joe',
      'lastName'  =&gt; 'Smith'
      )
  </code></pre>
  
  <p>I need to loop over every element in my array and in the end, the array should look like this:</p>
  
  <pre><code>array(
      'FirstName' =&gt; 'Joe',
      'LastName'  =&gt; 'Smith'
      )
  </code></pre>
  
  <p>Failed idea was:</p>
  
  <pre><code>    foreach($array as $key =&gt; $value)
      {
          $key = ucfirst($key);
      }
  </code></pre>
  
  <p>This obviously will not work, because the array is not passed by reference.  However, all these attempts also fail:</p>
  
  <pre><code>    foreach(&amp;$array as $key =&gt; $value)
      {
          $key = ucfirst($key);
      }
  
  
      foreach($array as &amp;$key =&gt; $value)
      {
          $key = ucfirst($key);
      }
  </code></pre>
  
  <p>Pretty much at my wits end with this one.  I'm using Magento 1.9.0.1 CE, but that's pretty irrelevant for this problem.  If you must know, the reason I have to do this is because I have a bunch of object that's I'm returning as an array to be assembled into a SOAP client.  The API I'm using requires the keys to begin with a capital letter...however, I don't wish to capitalize the first letter of my object's variable names.  Silly, I know, but we all answer to someone, and that someone wants it that way.</p>