Is there a way to split a comma separated string into a comma without blowing it up first and looping through the array? I have a row that is output from a database that appears as I showed below. Then I divided them into links.
But, given the string as it is, can I get it in the links without doing it the way I do below?
<?php
$tags = "fiction,non-fiction,horror,romance";
$tags = explode(',', $tags);
foreach( $tags as $tag ){
echo '<a href="'.$tag.'">'.$tag.'</a><br />';
}
?>
Last of the above:
<a href="fiction">fiction</a><br />
<a href="non-fiction">non-fiction</a><br />
<a href="horror">horror</a><br />
<a href="romance">romance</a><br />
source
share