Page 1 of 1

array results into comma seperated?

Posted: Sun Feb 18, 2007 8:12 pm
by ianhull
Hi Guys,

I would like to list the values of an array like this.

Code: Select all


$a = array("me", "and", "mydog");

//me, and, mydog

please help.

Thanks

Posted: Sun Feb 18, 2007 8:24 pm
by ianhull
nevermind :)

foreach

Posted: Sun Feb 18, 2007 8:51 pm
by Kieran Huggins
I think implode() would be a better choice for this

Posted: Sun Feb 18, 2007 8:52 pm
by ianhull
Still stuck

Code: Select all



   foreach ($varName as $varNames) {
   $varNames = $varNames.", ";
   }



how do i get this out of what I have here?

"me, and, mydog"

notice I need to remove the last comma

thanks

Posted: Sun Feb 18, 2007 8:56 pm
by ianhull
Hey thanks :)

implode();