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