Let\'s say I have this:
$array = array(\"john\" => \"doe\", \"foe\" => \"bar\", \"oh\" => \"yeah\"); foreach($array as $i=>$k) { echo $i.\'-\'.$
Alternatively you can use the rtrim function as:
$result = ''; foreach($array as $i=>$k) { $result .= $i.'-'.$k.','; } $result = rtrim($result,','); echo $result;