Comma after each item in array except last

As the title says, or of course it could be comma before each item except the first.

I have a custom field that returns an array. That part works fine with

<?php
$values = get('recording_details_genre');
   foreach($values as $value){
	   printf('%s',$value);
	   }
?>

I have tried various ways to control adding a comma and space between each item so that I do not end up with a trailing comma. I am no PHP wiz. After a couple of dozen combinations I cam up with this, is there a better way?

<?php
$values = get('recording_details_genre');
$count = count($values);
$i = $count;
   foreach($values as $value){
	   $i = $i -1;
	   if ($i < ($count - 1)) {
	   printf(', %s',$value); }
	   else{
	 printf('%s',$value);
   }
  }	
?>

http://www.php.net/implode

See example #1

With a comma space combo it sounds like you are trying to do something like this:


$str = "With my beer I like to eat ";
$stuff = array('chips','tacos','burgers','kebabs');
$last = array_pop($stuff);
$str .= join(', ', $stuff) . " and $last.";
echo $str;

// With my beer I like to eat chips, tacos, burgers and kebabs.