title: Laravel add commas between array elements
body: <p>I have this <strong>&quot;tags&quot; array</strong> and I want to add commas in between the links in my <strong>article.blade.php</strong>. Originally, this is the tags code:</p>
  <pre><code>&lt;b&gt;Tags:&lt;/b&gt; 
  @foreach($article-&gt;tags as $tag)
      &lt;a href=&quot;/tag/'{{ $tag-&gt;name }}&quot;&gt;{{ $tag-&gt;name }}&lt;/a&gt;
  @endforeach
  </code></pre>
  <p>I want this result</p>
  <pre><code>Tags: tag1, tag2, tag3
  </code></pre>
  <p>How do I do this so it looks right in an elegant way?</p>
  <p><strong>PS</strong>
  Meanwhile I found the solution. Here it is:</p>
  <h3><strong>[SOLUTION]</strong></h3>
  <p>The tags must be pre-defined in the controller(<strong>ArticlesController.php</strong>) here:</p>
  <pre><code>public function show(Article $article){     
      foreach($article-&gt;tags as $tag){
          $tags[]= link_to('tag/'.$tag-&gt;name, $tag-&gt;name, $tag-&gt;name);
      }   
      return view('page.article',compact('article','tags'));
  }
  </code></pre>
  <p>Next you can leave your <strong>articles.blade.ph</strong>p like this:</p>
  <pre><code>&lt;b&gt;Tags:&lt;/b&gt; 
  {!! implode(', ',$tags) !!}
  </code></pre>
  <p>Let me know if you can think of something better.</p>