<div class="username-info-area">
<img src="https://image5.sahibinden.com/users/47/06/46/p200_profile_14470646_8126809.png" class="user-profile-photo" height="50" width="50" alt="">
<h5>familya yapı Gayrimenkul Gyo ltd şti</h5>
</div>
I want to get h5 data. I can access div.username-info-area.
$items = $new_data->find('div.username-info-area', 0)->outertext;
echo $items . '<br>';
Run an if
clause inside of your foreach
loop, check this example out for instance:
The script below will make sure that if there's an h5
value it will print $div
and its outertext
.
<?php
foreach ($new_data->find('div[class=username-info-area]') as $div)
{
if($div->find('h5') !== '')
{
print_r($div->outertext);
}
}
?>
Or you can run another foreach
loop inside of the next foreach loop, for example.
<?php
foreach ($new_data->find('div[class=username-info-area]') as $div)
{
foreach($div->find('h5') as $h5)
{
print_r($h5->outertext);
}
}
?>
I hope this help.