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
JAB Creations
DevNet Resident
Posts: 2341 Joined: Thu Jan 13, 2005 6:44 pm
Location: Sarasota Florida
Contact:
Post
by JAB Creations » Sat Nov 22, 2008 10:16 am
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...
alex.barylski
DevNet Evangelist
Posts: 6267 Joined: Tue Dec 21, 2004 5:00 pm
Location: Winnipeg
Post
by alex.barylski » Sat Nov 22, 2008 10:59 am
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
Post
by mmj » Sat Nov 22, 2008 11:03 am
implode(',' $db_data);
?
(after you do what PCSpectra advises.
)