views:

78

answers:

1
foreach(self::getGroups() as $group) $group_ids[] = $group->getId();

Is there a better, cleaner and more efficient way to do that?

Thanks! :-)

+2  A: 

Well the only other way of doing that is with array_map() and it's not necessarily any quicker or better:

function get_id($group) {
  return $group->getId();
}

$group_ids = array_map('get_id', self::getGroups());
cletus
Ah ok. Thought as much. Thanks very much! :-) You've just confirmed that I wasn't being an idiot :P
Jamie