title: Array mapping in PHP with keys
body: <p>Just for curiosity (I know it can be a single line <code>foreach</code> statement), is there some PHP array function (or a combination of many) that given an array like:</p>
  
  <pre><code>Array (
      [0] =&gt; stdClass Object (
          [id] =&gt; 12
          [name] =&gt; Lorem
          [email] =&gt; lorem@example.org
      )
      [1] =&gt; stdClass Object (
          [id] =&gt; 34
          [name] =&gt; Ipsum
          [email] =&gt; ipsum@example.org
      )
  )
  </code></pre>
  
  <p>And, given <code>'id'</code> and <code>'name'</code>, produces something like:</p>
  
  <pre><code>Array (
      [12] =&gt; Lorem
      [34] =&gt; Ipsum
  )
  </code></pre>
  
  <p>I use this pattern a lot, and I noticed that <code>array_map</code> is quite useless in this scenario cause you can't specify keys for returned array.</p>