title: PHP: Separate array with commas
body: <p>I have this code that should display a list of values from an array followed by a comma and space! However I don't want the last one to have a comma and space after it.</p>
  
  <p>So for example I want <code>tag1, tag2, tag3</code> instead of <code>tag1, tag2, tag3,</code></p>
  
  <p>This is my code:</p>
  
  <pre><code>&lt;?php $terms = get_the_terms( $the_post-&gt;ID, 'posts_tags' );
                                  foreach ( $terms as $term ) {
  
                                      echo $term-&gt;name;echo ", ";
                                  } ?&gt;
  </code></pre>