3v4l.org

run code in 300+ PHP versions simultaneously
<?php $html = <<<HTML </li> <li > <div class="widget-post-holder"> <a href="/45214" title="care with your skin against pollution" class="post-thumb" > <span class="post-cont"> health </span> <div class="librLoaderLine"></div> <img title="care with your skin against pollution" id="0045214" class="te lazy js-postPreview" data-src="https://wemedic.com/media/posts/201105/23/45214/original/14.jpg" src="https://wemedic.com/media/posts/201105/23/45214/original/14.jpg" data-libr="https://healthandc.com/media/posts/201105/23/45214/libr_225k_45214.webm" alt="care with your skin against pollution" /> <span class="hd-post" onclick="window.location.href ='/45214'"></span> </a> </li> <li > <div class="widget-post-holder"> <a href="/7487423" title="natural hair straightening" class="post-thumb" > <span class="post-cont"> health </span> <div class="librLoaderLine"></div> <img title="natural hair straightening" id="0045214" class="te lazy js-postPreview" data-src="https://wemedic.com/media/posts/201105/23/7487423/original/14.jpg" src="https://wemedic.com/media/posts/201105/23/45214/original/14.jpg" data-libr="https://healthandc.com/media/posts/201105/23/7487423/libr_225k_7487423.webm" alt="care with your skin against pollution" /> <span class="hd-post" onclick="window.location.href ='/7487423'"></span> </a> HTML; $dom = new DOMDocument(); libxml_use_internal_errors(true); $dom->loadHTML($html, LIBXML_HTML_NOIMPLIED | LIBXML_HTML_NODEFDTD); $xpath = new DOMXPath($dom); $results = []; foreach ($xpath->query('//*/@href') as $val) { if (preg_match('~^/\d{4,}$~', $val->value)) { array_push($results, $val->value); } } print_r($results);

preferences:
31.38 ms | 407 KiB | 5 Q