Transform a complex array from a dql query to a simple one returning just selected entries

Transform a complex array from a dql query to a simple one returning just selected entries

I have written a dql query:

$emails = $manager->createQuery('SELECT (u.email) as email FROM AppEntityUser u')->getResult();

That returns:

Array

I would like to transform it in a simple array who’ll list directly the emails like:

$emails = ["email1", "email2", "email3", "email4" ...];

Does anyone could help me with that?.

Source: Symfony Questions

Leave a Reply

Your email address will not be published. Required fields are marked *