Looks like a foreach loop is the fastest. Syntax is a matter of taste, I guess.
EDIT
As I said in my response to David's post, I have in fact benchmarked this.
for($i = 0;$i<=8000;$i++){
$users[] = (object)array("email"=>rand(0,15));
}
$arrMapBm = new nzpBM("arrMap");
$foreachBm = new nzpBM("foreach");
$arrMapBm->start();
$emails = array_map(function ($user) { return $user->email; }, $users);
echo $arrMapBm;
unset($emails);
$foreachBm->start();
foreach($users as $user) {
$emails[] = $user->email;
}
echo $foreachBm;
Gives pretty solid results.
The benchmark "arrMap (1)" took 4.8160552978516 miliseconds
The benchmark "foreach (1)" took 2.1059513092041 miliseconds
I don't know if this is because I am on a windows machine at the moment, but for me, array_map is definetedly NOT faster. Not trying to mislead anyone here.