php将特定字符更改为html标签

发布于 2024-12-21 22:09:27 字数 247 浏览 2 评论 0原文

我的数据库中存储了一些文本数据,我希望它以特定的方式显示:我按照维基百科标准存储数据,例如:

==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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

痴者 2024-12-28 22:09:27

有许多用于解析和呈现 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

御守 2024-12-28 22:09:27

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文