mercredi 28 octobre 2015

Laravel add commas between array elements

I just started learning laravel..

I have this "tags" array and I want to add commas between the links in my article.blade.php, like so:

Tags:
@foreach($article->tags as $tag)
    {{ $tags[] = '<a href="/tag/'. $tag->name .'">'.$tag->name .'</a>' }}
@endforeach
{!! implode(',',$tags) !!}

So it must become this:

Tags: tag1, tag2, tag3

And not this:

Tags: <a href="/tag/fun">fun</a> <a href="/tag/sports">sports</a> <a href="/tag/work">work</a> fun,sports,work

How do I do this so it looks right?



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/1jSUOMZ
via IFTTT

Aucun commentaire:

Enregistrer un commentaire