Category: arrays

I need to find the max population of an area code in an array that has duplicate area code keys in PHP [closed]

I have an array that is pulling the following out of a CSV file $results[] = array( ‘areaCode’ => $areaCode, ‘city’ => $data[$headers[‘name’]], ‘state’ => $data[$headers[‘state_code’]], ‘population’ => $data[$headers[‘population’]], ); There are multiple instances of the same $areaCode. I need…

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: I would like to transform it in a simple array who’ll list directly the emails like: $emails = [“email1”, “email2”, “email3”, “email4” …];…