<?php
$data = <<<DATA
<p>a lot of some html code here</p>
<p class="price"> <strong>2680 $</strong>
<div>a lot of some random html code here</div>
<p class="price"> <strong>3250 $</strong>
<p>a lot of some good html code here</p>
<p class="price"> <strong>3450 $</strong>
<div id="promoted-after"></div>
<p class="price"> <strong>400 $</strong>
<td>a lot of some strange html code here</td>
<p class="price"> <strong>401 $</strong>
<div>a lot of some awesome html code here</div>
<p class="price"> <strong>402 $</strong>
<span>a lot of some ugly html code here</span>
<p class="price"> <strong>403 $</strong>
<div>a lot of some nice html code here</div>
<p class="price"> <strong>404 $</strong>
<table>a lot of some best html code here</table>
DATA;
$dom = new DOMDocument();
$dom->loadHTML($data);
$xpath = new DOMXPath($dom);
$items = $xpath->query('//div[@id="promoted-after"]/following-sibling::p/strong');
foreach($items as $item) {
echo $item->nodeValue . PHP_EOL;
}
Warning: PHP Startup: Unable to load dynamic library 'sodium.so' (tried: /usr/lib/php/8.3.5/modules/sodium.so (libsodium.so.23: cannot open shared object file: No such file or directory), /usr/lib/php/8.3.5/modules/sodium.so.so (/usr/lib/php/8.3.5/modules/sodium.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
400 $
401 $
402 $
403 $
404 $