Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ssis/2.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 部分body标签保留在文件\u get\u contents输出中,如何删除它_Php - Fatal编程技术网

Php 部分body标签保留在文件\u get\u contents输出中,如何删除它

Php 部分body标签保留在文件\u get\u contents输出中,如何删除它,php,Php,我使用file_get_contents获取网页内容,部分body标记保留在输出中。我还使用strip_tags()删除其他html标记,但部分正文标记仍然保留 我怎样才能删除它 我得到的输出是body>然后是content 这是我的密码: $content = file_get_contents( $url ); $content = stristr( $content, "body" ); echo strip_tags($content); stristr从匹配字符串开始的索引开始返回,

我使用file_get_contents获取网页内容,部分body标记保留在输出中。我还使用strip_tags()删除其他html标记,但部分正文标记仍然保留

我怎样才能删除它

我得到的输出是body>然后是content

这是我的密码:

$content = file_get_contents( $url );
$content = stristr( $content, "body" );
echo strip_tags($content);

stristr
从匹配字符串开始的索引开始返回,但实际上在其结束后返回一个字符:


这将返回以
开头的内容,这些内容将被
剥离标签剥离

您到底要做什么?将网站嵌入您的页面?还是要从该页面提取特殊信息?
$content = substr(strpos($content, "<body>") + strlen("<body>") + 1);
$content = stristr($content, "<body>");