I have an array, $names, that looks like this:
$names = array("Joe", "Jill", "Bill);
I've used the following code to list the contents of the above array:
<?
if (isset($names)){
echo ("Here's your list of names: ");
foreach ($names as $x)
echo "($x, ");
}
?>
And here's what I get:
Joe, Jill, Bill,
What I need is the above string without the last comma. Is there a string function that will strip the last comma from the string? Or is there a way to modify the above code to accomplish this?
Your thoughts will be appreciated.




implode() the array:


Bookmarks