php - remove commas from a string, and also print code for each word before and after the comma -
hopefully question title makes sense.
just wondering if possible data record in mysql, remove commas , print each item individually?
i have column called tags, , example in 1 of records tags
"rock,bass,alternative"
what want remove commas , print html code <a href ="/tag name">
before , </a>
after each individual tag.
so far code :
$id = $_get['id']; $station = mysql_query ( "select * `stations` `id` = '$id'" ); $sta = mysql_fetch_object ( $station ); <? echo "$sta->tags";?>
explode on ,
, giving array, print each item , concatenate string encapsulstaion.
$tags = explode(',', $sta->tags); foreach($tags $tag): echo "$tag"; endforeach;
Comments
Post a Comment