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

Popular posts from this blog

how to proxy from https to http with lighttpd -

android - Automated my builds -

python - Flask migration error -