这是我的代码
$str="<div>this is the variable</div>";
Run Code Online (Sandbox Code Playgroud)
我想删除它的html标签<div>而不使用strip_tags.我需要$str="this is the variable"
因为我的服务器不能使用strip_tags.我知道preg_replace是可行的.但我不知道正则表达式.所以请建议我的解决方案.
先感谢您.
如果DIV标记包含属性,则此变体也适用:
$str = '<div id="some_id">this is the variable</div>';
$str = preg_replace('/\<[\/]{0,1}div[^\>]*\>/i', '', $str);
echo $str;
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
14072 次 |
| 最近记录: |