我已更改$content = "
<html>
<head>
<title>test</title>
</head>
<body>
<div class='param1'>Some text 1 <p>:)</p></div>
<div class='param2'>Some text 2</div>
</body>
</html>
";
并在此更改html代码中保存另一个网站。
例如:
==
我怎么能用这个div的所有内容来销毁标签?
谢谢。
答案 0 :(得分:2)
我认为这就是你所追求的:
$content = "
<html>
<head>
<title>test</title>
</head>
<body>
<div class='param1'>Some text 1 <p>:)</p></div>
<div class='param2'>Some text 2</div>
</body>
</html>
";
$pattern = "/<div class='param1'>.*<\/div>/";
$content = preg_replace($pattern, '', $content);
header('Content-type: text/plain');
echo $content;
<强>输出强>
<html>
<head>
<title>test</title>
</head>
<body>
<div class='param2'>Some text 2</div>
</body>
</html>