giodamelio giodamelio - 1 year ago 82
PHP Question

PHP Add comma to every item but last one

I have a loop like

foreach ($_GET as $name => $value) {
echo "$value\n";

And I want to add a comma in between each item so it ends up like this.

var1, var2, var3

Since I am using
I have no way to tell what iteration number I am on.

How could I do that?

Answer Source

Sorry I did not state my question properly. The awnser that worked for me is

implode(', ', $_GET);

Thanks, giodamelio

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download