Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/236.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/email/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 使用str_replace删除某些html标记_Php_Str Replace - Fatal编程技术网

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');
您应该添加更多关于源文本外观的信息。