This seems like it should be (and probably is) trivial. I have a simple query:
SELECT Name From User;
When I run the query using this code:
$rows = $preparedStatement->fetchAll(PDO::FETCH_ASSOC);
$Rows looks like this:
Array ( [0] => Array ( [Name] => Doug ) [1] => Array ( [Name] => John ) )
Is there an easy way to make the array look something like this:
Array( Doug, John)
Using the constant PDO::FETCH_COLUMN:
This way you’ll get exactly what you proposed.
You can also do the following:
This way you’ll get an array with unique values.
Source: http://www.php.net/manual/en/pdostatement.fetchall.php