在一个简单的html dom抓取变量中删除一个特定的图像


Remove a specific image in a simple html dom scrape variable

我创建了下面的foreach语句,它遍历$gosu_full->find('img')中的所有图像。然而,有一个特定的图像,我想删除,这是$img->src == $gosu_img。到目前为止,我试图将$img->src设置为空字符串和unset($img),但没有任何作用。我怎么做才能去掉它?

foreach($gosu_full->find('img') as $img) {
                if  (stripos($img->src,'http://www.gosugamers.net') == true) {
                } else {
                    $img->src = "http://www.gosugamers.net" . $img->src;

                    if ($img->src == $gosu_img){
                        unset($img);
                    }
                }

}

我认为你应该重写img标签的html代码

$img->outertext = '';