Create a comma-separated string from a single column of an array of objects

Better:

$resultstr = array();
foreach ($results as $result) {
  $resultstr[] = $result->name;
}
echo implode(",",$resultstr);

Leave a Comment