Page 1 of 1

Convert MySQL array in to normal array?

Posted: Sat Nov 22, 2008 10:16 am
by JAB Creations
What is the best method to convert a MySQL array in to a normal array?

Code: Select all

Array ( [0] => 36 [tag_id] => 36 )
Array ( [0] => 37 [tag_id] => 37 )
Array ( [0] => 38 [tag_id] => 38 )
...to...

Code: Select all

36,37,38

Re: Convert MySQL array in to normal array?

Posted: Sat Nov 22, 2008 10:59 am
by alex.barylski
Well for starters I always specify whether to return the array as a ASSOC or NUMERIC (or whatever it is) never both. It's a waste of memory.

I typically would iterate over the result set and store each record in a native PHP array...

WHy how are you doing it currently?

Re: Convert MySQL array in to normal array?

Posted: Sat Nov 22, 2008 11:03 am
by mmj
implode(',' $db_data);

?

(after you do what PCSpectra advises. ;))