Q:

Looping For in PHP (add , into array)

This is my code :
$query = mysql_query("SELECT * FROM `member` ORDER BY Code");
$fieldNum = mysql_num_fields($query);
for($q=0; $q<$fieldNum; $q++){
    $value = "'value$q'";
    echo "$value";
    echo ",";
}

I want the output
value0,value1,value2, ... ,value5
but I got the output
value0,value1,value2, ... ,value5,
I want to delete a last comma, what should I do?

A:

Simple way
$value = array();
for($q=0;$q<$fieldNum;$q++){
        $value [] = 'value'.$q;
      }
echo implode (',', $value);

http://php.net/manual/en/function.implode.php

