I have a result set that is being returned using this code:
while ($row = mysql_fetch_array( $result )) {
echo "ID ".$row['v2id'];
}
this returns ID 2ID 3ID 4ID 8
how would i convert this to comma separated values and then store them in a variable?
so if i echoed out the variable, the final output would should look like 2, 3, 4, 8
store all the values in an array, then join them using ", " as the glue
$values = array();
while ($row = mysql_fetch_array( $result )) {
$values[] = $row['v2id'];
}
echo join(", ", $values);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With