title: How to remap array keys (based on values) with PHP?
body: <pre><code>&lt;?php
  
  // get unordered array of Group objects
  $groups = $this-&gt;getDoctrine()-&gt;getManager()-&gt;getRepository('AcmeDemoBundle:Group');
  
  $array = array();
  // map array to $groupName =&gt; $groupObject
  foreach ($groups as $group) {
      $array[$group-&gt;getName()] = $group;
  }
  </code></pre>
  
  <p>Is there a shorter way to do that in PHP?</p>
  
  <blockquote>
    <p>Note: Group names are unique, not empty strings.</p>
  </blockquote>
  
  <p>I was thinking about <code>array_walk</code>, but I'm not sure if can replace the key somehow?</p>