php - **文本**中的粗体文本标记php
问题描述
我正在使用此函数为用户名着色,以防它存在@username
于字符串中。
PHP
$string="this **text** contains a second **content**"
我想加粗文本中包含的文本
我试过但没有
function bold_word($string) {
return preg_replace('/(\**+)/', "<b>$1</b>", $string);
}
解决方案
推荐阅读
- java - 为什么时间限制超出问题显示在一个代码中,而在另一个代码中通过测试用例?
- javascript - 使用 Javascript 中未知数组和函数参数长度的数组值运行函数
- php - 层次树遍历 (Laravel/PHP)
- android - Android 从本地数据分页(无空间)
- python - 安装 CSV 模块时获取 AttributeError 的所有方法
- asp.net-web-api - Swagger Bearer Authentication 未显示 [GET] 请求的授权 JWT 令牌字段
- python - 在数据帧上使用多索引时出现 KeyError
- c# - 数据库注册表未完全更新
- r - 如何比较一段时间内的温度数据
- css - 对 SVG 使用无填充而不是颜色