开发者

issue with a php tag system

I am trying to set up a 开发者_如何学JAVAtagging system, but i am having a little diffuculty here, if someone could help i would be very appreciative, anyhow i am just trying to query the database for the tags which are stuck into a row in the database of a table, and each tag is seperated by a comma, well i am trying to take each of those tags and create a link out of each one.

once i query the database the output basically looks as follows:

tag1, tag2, tag3, tag4, tag5, tag6

and i want to be able to separate them.


If you already have a comma seperated value from the database, you can use a regex to print out the tags:

echo preg_replace( "/([a-z]+)/", "<a href=\"#$1\">$1</a>", $str ); It just goes through searching for a-z words and converts them in to links.

Some other options could be:

  • preg_replace_callback()
  • explode() (as the other user said)


This is a very good way of implementing tagging system.

http://www.phpro.org/tutorials/Tagging-With-PHP-And-MySQL.html

other way is using explode()

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜