PHP < 5.5
You can use array_map
, and since you only have on item per array, you can elegantly use
'current'
as callback, instead of writing a closure.
$result = $em->createQuery("SELECT a.id FROM Auction a")->getScalarResult();
$ids = array_map('current', $result);
See Petr Sobotka’s answer below for additional info regarding memory usage.
PHP >= 5.5
As jcbwlkr’s answered below, the recommended way it to use array_column
.