3v4l.org

run code in 300+ PHP versions simultaneously
<?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; }
Output for 5.6.0 - 5.6.40, 7.0.0 - 7.0.33, 7.1.0 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.19, 8.3.0 - 8.3.4, 8.3.6 - 8.3.7
400 $ 401 $ 402 $ 403 $ 404 $
Output for 8.3.5
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 $

preferences:
162.79 ms | 402 KiB | 289 Q