-2

I fetch a column value during a query, I store each row value in an array:

while($stmt->fetch()){
    $category_array[]=array($category);
}

The result looks like this in the console:

category_array: Array(3)
0: ["Automotive Care"]
1: ["Automotive Care"]
2: ["Digital Service"]

I am trying to combine these into a single array that looks like:

["Automotive Care","Automotive Care","Digital Service"]

This array may have more than these results. So it has to be able to process whatever comes its way. I am unable to find the right PHP function that allows me to do this. Which function should I use?
thanks!

0

1 Answer 1

1

Simply change the code to remove the unnecessary array()

while($stmt->fetch()){
    $category_array[] = $category;
}
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.