Sunday, May 8, 2016

Convert A Table To Comma Separated String Using PHP

Today I will show you how can you convert a table to a comma separated string in PHP.

This small piece of code will help you achieve this target.

$field1Values = array();
while($row = mysql_fetch_assoc($result))
{
$field1Values[] = $row[field1];
}

$field1List = implode(, , $field1Values);

Hope this code nudges you onto the right path.

If the script above worked for you and you really like our blog then consider subscribing for free in order to receive all future updates right in your Inbox.

Enjoy!