【发布时间】:2012-09-11 18:48:56
【问题描述】:
这是我的代码
$str="<div>this is the variable</div>";
我想在不使用 strip_tags 的情况下删除它的 html 标签<div>。
我需要$str="this is the variable"
因为我的服务器没有使用 strip_tags。
我知道 preg_replace 是可能的。但我不知道正则表达式。
所以请给我建议解决方案。
提前谢谢你。
【问题讨论】:
-
除非您使用的是 PHP 3(我希望 noone 是这样),否则
strip_tags应该可以工作.... -
$str = preg_replace("<div>", "", "<div>this is the variable</div>"); $str = preg_replace("</div>", "", "<div>this is the variable</div>");php.net/manual/en/function.preg-replace.php -
@TWCrap 不,不要! $str = preg_replace("?div>","",$str);