作者热门文章
- android - RelativeLayout 背景可绘制重叠内容
- android - 如何链接 cpufeatures lib 以获取 native android 库?
- java - OnItemClickListener 不起作用,但 OnLongItemClickListener 在自定义 ListView 中起作用
- java - Android 文件转字符串
我想编码 ( htmlentities
) 或禁用除 <a>
之外的所有标签标签。
我怎样才能做到这一点?
最佳答案
使用 HTML 实体后,使用 RegExp 将链接转换回:
preg_replace('/<(\/?a(?:|\s[\S\s]+?))>/i', '<$1>', $string);
如果你想删除其他标签,使用:
strip_tags($string, '<a>');
关于php - 禁用除 <a> 之外的所有标签,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7861369/
我是一名优秀的程序员,十分优秀!