문제

Hi i'm having below html structure,

<div id="main">
 <div class="contents">
  <div class="title">....</div>
  <div class="image"><img src="imagepath" /></div>
 </div>
</div>

Using below code i'm collecting all it's contents.

$description = trim(@$html->find('div[id=main]', 0)->innertext);

Now i'm trying to remove images within <div id="main"></div>

so far i tried @$html->find('div[class=image]', 0)->innertext = '';

But no changes. Any solution to solve this?

도움이 되었습니까?

해결책

You were close, you want to use outertext:

$div = $html->find('#main', 0);
foreach($div->find('.image') as $img) $img->outertext = '';
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top