Jump to content


This topic is now archived and is closed to further replies.


going crazy over "implode"

Recommended Posts

Hi Folks...

I'm going nuts with this implode function. I just need to list a distinct group of cities pulled from a database as a comma separated list with no comma after the last city. So I have been playing with this and the best I can do is get it to list each city name twice. Can you see something that I'm missing?

while ($row= mysql_fetch_array($result)){
echo implode(', ', $row);

Thanks, in advance!

Share this post

Link to post
Share on other sites
Use [i]mysql_fetch_assoc()[/i] or [i]mysql_fetch_array($result,MYSQL_ASSOC)[/i]

To elaborate:
[b]mysql_fetch_array [/b] ( resource result [, [u][i]int result_type[/i][/u]] )

The type of array that is to be fetched. It's a constant and can take the following values: MYSQL_ASSOC, MYSQL_NUM, [u]and the default value of MYSQL_BOTH[/u].

Leaving "result_type" will return values twice; once with numeric, once with associative keys.

Share this post

Link to post
Share on other sites


Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.