正则菜鸟求救
这里发言,表示您接受了CSDN论坛的用户行为准则。
请对您的言行负责,并遵守中华人民共和国有关法律法规,尊重网上道德。
转载文章请注明出自“CSDN(www.csdn.net)”。如是商业用途请联系原作者。
怎么把a标记去掉,只留下行为准则。小弟先谢谢了
public function strip_selected_tags($text, $tags = array())<br />
{<br />
$args = func_get_args();<br />
$text = array_shift($args);<br />
$tags = func_num_args() > 2 ? array_diff($args,array($text)) : (array)$tags;<br />
foreach ($tags as $tag){<br />
if(preg_match_all('/<'.$tag.'[^>]*>(.*)<\/'.$tag.'>/iU', $text, $found)){<br />
$text = str_replace($found[0],$found[1],$text);<br />
}<br />
}<br />
<br />
return $text;<br />
}<br />
$text = '<a href="www.baidu.com">行为准则</a>的撒的发的是发烧的发的';<br />
echo strip_tags($text);<br />
echo strip_tags($text, '<a>');<br />
<br />
每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号