What would be a direct way to turn comma separated data from a mysql table, into a simple php array, other than doing it like I'm doing now?
I current do this in a very messy way by selecting data, then concatenating it into a string, which I later use.
I'm using PDO here.
Data is simple
locations
-------------------
US,UK,SE,DE
DE,SE,CA
GB,US,DE,SE
AU,NZ,GB
pdo
$d = $db->prepare('select locations a from destinations');
$d->execute();
$d->bindColumn('a',$a);
$count = $d->rowCount();
if($count >= 1) {
$b = '';
while($row = $d->fetch()) {
$b .= $a.',';
}
} else {
$b = 'No records to display';
}
echo $b;
The output I'm hoping to achieve is just a simple array like below, which is all the rows joined together.
Desired output
array('US','UK','SE','DE','DE','SE','CA','GB','US','DE','SE','AU','NZ','GB')
Can you help?