php将特定字符更改为html标签
我的数据库中存储了一些文本数据,我希望它以特定的方式显示:我按照维基百科标准存储数据,例如:
==title==
some ''data''
我希望这些数据被转换为 < /code>、
、
等。 是否有任何函数/解析器可以轻松实现此目标?
I have some text data stored in my database, and I want it to be displayed in an specific way: I store the data followind wikipedia standard, for example:
==title==
some ''data''
And I want this data to be translated to <b>
, <h2>
, <i>
, etc.
Is there any function/parser to easily achive this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
有许多用于解析和呈现 MediaWiki 标记的库,其中包括一些用 PHP 编写的库。请参阅http://www.mediawiki.org/wiki/Alternative_parsers
There are numerous libraries for parsing and rendering MediaWiki markup, including some written in PHP. See http://www.mediawiki.org/wiki/Alternative_parsers
PHP 的
str_replace($search, $replace, $subject)
函数可以将数组作为参数,并将 $subject 中每次出现的 $search 元素替换为 $replace 中相应的元素。请参阅http://php.net/manual/en/function.str-replace。 php
PHP's
str_replace($search, $replace, $subject)
function can take arrays as parameters, and replaces each occurence of $search's elements in $subject with the respective element of $replace.See http://php.net/manual/en/function.str-replace.php