Convert MySQL array in to normal array?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
JAB Creations
DevNet Resident
Posts: 2341
Joined: Thu Jan 13, 2005 6:44 pm
Location: Sarasota Florida
Contact:

Convert MySQL array in to normal array?

Post 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
alex.barylski
DevNet Evangelist
Posts: 6267
Joined: Tue Dec 21, 2004 5:00 pm
Location: Winnipeg

Re: Convert MySQL array in to normal array?

Post 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?
mmj
Forum Contributor
Posts: 118
Joined: Fri Oct 31, 2008 4:00 pm

Re: Convert MySQL array in to normal array?

Post by mmj »

implode(',' $db_data);

?

(after you do what PCSpectra advises. ;))
Post Reply