title: How can I define variable array on the laravel blade view?
body: <p>I try like this :</p>
  
  <pre><code>&lt;div class="media-body"&gt;
      @foreach($categories as $category)
      @php $category[] = $category-&gt;name @endphp
      @endforeach   
      {{ implode(",", $category) }}
  &lt;/div&gt;
  </code></pre>
  
  <p>If the code executed, there exist error :</p>
  
  <blockquote>
    <p>undefine variable category</p>
  </blockquote>
  
  <p>How can I solve it?</p>