Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/arduino/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
跳过div简单html dom中的div_Dom_Simple Html Dom - Fatal编程技术网

跳过div简单html dom中的div

跳过div简单html dom中的div,dom,simple-html-dom,Dom,Simple Html Dom,我想从中提取数据的页面包含以下元素 <div class="content"> <p>I want this</p> <p>I want this</p> <div class="row"> <p>I do not want this</p> <p>I do not want this</p> </div> </div> 我想要

我想从中提取数据的页面包含以下元素

<div class="content">
 <p>I want this</p>
 <p>I want this</p>
 <div class="row">
   <p>I do not want this</p>
   <p>I do not want this</p>

 </div>
</div>

我想要这个

我想要这个

我不要这个

我不要这个

我不想在
这就是我迄今为止所尝试的。似乎不起作用

foreach ($sample_html->find('div[class=entry-content]') as $content) {

                foreach($content->find('div[class=row]') as $row){

                    foreach ($row->find('p') as $skip) {

                        $skip->outertext = '';
                    }
                }

                foreach($content->find('p') as $paragraph){

                    //echo $paragraph;
                    $paragraphs .= '<p>'.$paragraph->innertext.'</p>';
                    echo $paragraphs;
                }


            }
foreach($sample\u html->find('div[class=entry content]”)作为$content){
foreach($content->find('div[class=row]')作为$row){
foreach($row->find('p')作为$skip){
$skip->outertext='';
}
}
foreach($content->find('p')as$段落){
//回音$段;
$段落=“”。$段落->内部文本。

”; 回音$段; } }
更改

 $skip->outertext = '';

 $skip->innertext= '';