After running a query, I get an array of results (articles) where each of them has their properties like id
, name
and tags
.
This is the code where I display those values:
@foreach ( $results['matches'] as $doc => $docinfo )
...
{{$docinfo['attrs']['s_tags']}}
@endforeach
But the problem is that some of articles have a long list of tags, for example:
"s_tags" => "Tech, geben, rasant, Wechsel, Pakete, Kunden, Details, Intel, Microsoft, Angebote, App, Web"
How can I assure that maximum 5 tags are displayed. So in this case it would be:
"Tech, geben, rasant, Wechsel, Pakete"
and of course, if there are articles with the number of tags less than 5, I want to display them all.