I am running this foreach loop. I need to seperate each value by a comma, which this does. However, I need to kill the comma on the last value.
foreach ($_POST as $key=>$value){
if ($key != "submit" && $key != "type"){
$fields = $key.",";
echo $fields;
}
}
This returns this:
name,title,organization,city,state,
I need it to return this:
name,title,organization,city,state
NO COMMA AFTER THE LAST VALUE, WHICH ISNT ALWAYS STATE.
I tired rtrim and ltrim but it removes all the commas.
Thanks in advance.