Php 使用str_replace删除某些html标记
可能重复:Php 使用str_replace删除某些html标记,php,str-replace,Php,Str Replace,可能重复: 我有一个带有一些不需要的html标记的数据库,我需要保留一些html格式。我尝试使用str_replace删除不需要的标记,但无效: $newdrp = str_replace('<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd"><html>',"",$row_Recordset1['full_de
我有一个带有一些不需要的html标记的数据库,我需要保留一些html格式。我尝试使用str_replace删除不需要的标记,但无效:
$newdrp = str_replace('<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd"><html>',"",$row_Recordset1['full_description']);
$newdrp=str_replace(“”,$row_Recordset1['full_description');
如果您只想允许使用某些标记,您可以使用:
$newdrp = strip_tags($row_Recordset1['full_description'], '<span> <div>');
$newdrp=strip_标签($row_Recordset1['full_description'],'');
如果要删除所有html,请使用以下命令:
$newdrp = strip_tags($text);
$newdrp = strip_tags($text, '<div> <a>');
$newdrp=带标签($text);
如果您只想删除一些html,请使用以下命令:
$newdrp = strip_tags($text);
$newdrp = strip_tags($text, '<div> <a>');
$newdrp=strip_标签($text');
您应该添加更多关于源文本外观的信息。