title: how to store database values in an array with comma seperated values
body: <p>I am looking to store the database values which are already stored as id's and retrieve via a for each loop within an array.</p>
  
  <p>I have tried something like this, but it is not working:</p>
  
  <pre><code>foreach ($list as $item)
  {
       $commaSeparated = implode(',' , $item['id');
  }
  echo $commaSeparated;
  </code></pre>
  
  <p>Where <code>item['id']</code> is the specific column pulled out of the query.  If I use the $list variable, then I am getting the full result of the query which I do not want.</p>
  
  <p>But, my error results in this:</p>
  
  <pre><code>Warning: implode(): Invalid arguments passed 
  </code></pre>
  
  <p>This is what has correctly returned what I need:</p>
  
  <pre><code>foreach ($list as &amp;$id)
          {
  
              $listArr[] = $id['toolbar_id'];
  
              $commaSeparated = implode(',' , $listArr)
  
                               echo $commaSeparated;
  </code></pre>