Is it possible with php to make a string of, say, <a>
-elements comma-separated?
The situation is that a foreach
loop appends a number of <a>
links to an $output
variable one after the other:
$output = '<a>link</a><a>link</a><a>link</a><a>link</a><a>link</a>';
Is it afterwards possible in php to comma-separate them and achieve the below string?
$output = '<a>link</a>,<a>link</a>,<a>link</a>,<a>link</a>,<a>link</a>';
Or is the most efficient way to add the comma inside the foreach
loop (and then to use an if
-command to skip the last one, or something like that, since that will add one comma too many)?