I'm trying to take a result from fetchAll and to take some of the data and put it into an array.
Relevant PHP:
$catcodessql = "select distinct cat_code from mytable";
$result2 = $dbh->query($catcodessql)->fetchAll(PDO::FETCH_ASSOC);
This returns something like below:
array(4) {
[0]=>
array(1) {
["cat_code"]=>
string(3) "edu"
}
[1]=>
array(1) {
["cat_code"]=>
string(3) "inc"
}
[2]=>
array(1) {
["cat_code"]=>
string(3) "net"
}
[3]=>
array(1) {
["cat_code"]=>
string(3) "occ"
}
What I want is all those strings so I can dynamically put together this line later in my PHP:
$allcategories = array ('edu', 'inc', 'net', 'occ' );
So, I need to create a variable that will replace this part: 'edu', 'inc', 'net', 'occ'
I've tried a couple of while functions, but clearly they aren't right.
$allcategories = array ('edu', 'inc', 'net', 'occ' )?