php - 想要内爆列表以及一些 html 标签

标签 php

我在我的 tumblr api 网站中有这个 php 函数,它生成格式为标签的列表

[ Tag1,Tag2,Tag3 ]

我想让它以这种格式输出标签

[<b class="tagsingle">Tag1</b>,<b class="tagsingle">Tag2</b>,<b class="tagsingle">Tag3</b>]

这是内爆 php 行和打印标签列表的另一行。

$tags = ($row->tumblr_tag != NULL)? $row->tumblr_tag : implode(',&nbsp ',$post->tags);
echo '<p class="tags">'.$tags.'</p></div>

谁能告诉我该怎么做?

提前致谢。

最佳答案

试试这个:

$tagsString = implode('</b>, <b class="tagsingle">',$post->tags);
echo '<p class="tags"><b class="tagsingle">'.$tagsString.'</b></p>';

这应该导致:

<p class="tags">
    <b class="tagsingle">Tag1</b>
    <b class="tagsingle">Tag2</b>
    ...
</p>

关于php - 想要内爆列表以及一些 html 标签,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40907831/

相关文章:

PHP/SSH 正则表达式脚本/命令,用于从多个文件中删除相同的恶意软件代码

javascript - 保护 SPA HTML5 应用程序和 Web 服务之间的用户 token ?

php - 奇怪的 JSON 键?

php - 我不断收到这些错误。伊和 pear

php - 在 php unlink 中使用通配符

php - 从外部页面获取div,然后从中删除另一个div

php - 查询数据库来自

php - mysqli 数组获取未获取数据

php - Laravel 4 从本地主机发送电子邮件到 gmail

PHP 时区转换/PHP 日期未显示正确的时区