3v4l.org

run code in 300+ PHP versions simultaneously
<?php $html = '<table> <tr class="rules-details" style="display: none"> <td colspan="4"> <a href="/serve-scaled-images.html" class="rule-help btn hover-tooltip" data-tooltip-interactive data-tooltip-max-width="450" title="&lt;h4&gt;Serve scaled images&lt;/h4&gt;&lt;p&gt;Serving appropriately-sized images can save many bytes of data and improve the performance of your webpage, especially on low-powered (eg. mobile) devices.&lt;/p&gt;&lt;p class=&quot;rule-help-tooltip-more&quot;&gt;&lt;a href=&quot;/serve-scaled-images.html&quot;&gt;Read more&lt;/a&gt;&lt;/p&gt;"><i class="sprite-question"></i><span class="resp-hidden">What\'s this mean?</span></a> <div> <p>The following images are resized in HTML or CSS. Serving scaled images could save 1.3MiB (45% reduction). <ul> <li><a href="https://www.example.com/Pictures/thumbs/0029.jpg" target="_blank" rel="nofollow noopener noreferrer">https://www.example.com/Pictures/thumbs/0029.jpg</a> is resized in HTML or CSS from 300x623 to 123x200. Serving a scaled image could save 51.3KiB (86% reduction).</li> <li><a href="https://www.example.com/Pictures/thumbs/0133.jpg" target="_blank" rel="nofollow noopener noreferrer">https://www.example.com/Pictures/thumbs/0133.jpg</a> is resized in HTML or CSS from 300x578 to 135x200. Serving a scaled image could save 44.0KiB (84% reduction).</li> <li><a href="https://www.example.com/Pictures/thumbs/0075.jpg" target="_blank" rel="nofollow noopener noreferrer">https://www.example.com/Pictures/thumbs/0075.jpg</a> is resized in HTML or CSS from 300x390 to 176x200. Serving a scaled image could save 43.2KiB (69% reduction).</li> <li><a href="https://www.example.com/Pictures/thumbs/0057.jpg" target="_blank" rel="nofollow noopener noreferrer">https://www.example.com/Pictures/thumbs/0057.jpg</a> is resized in HTML or CSS from 300x436 to 174x200. Serving a scaled image could save 35.0KiB (73% reduction).</li> <li><a href="https://www.example.com/Pictures/thumb/thumb.png" target="_blank" rel="nofollow noopener noreferrer">https://www.example.com/Pictures/thumbs/thumb.png</a> is resized in HTML or CSS from 148x100 to 68x46. Serving a scaled image could save 31.4KiB (78% reduction).</li> <li><a href="https://www.example.com/Pictures/thumb/thumb.png" target="_blank" rel="nofollow noopener noreferrer">https://www.example.com/Pictures/thumbs/thumb.png</a> is resized in HTML or CSS from 148x100 to 68x46. Serving a scaled image could save 30.9KiB (78% reduction).</li> <li><a href="https://www.example.com/Pictures/thumb/thumb.png" target="_blank" rel="nofollow noopener noreferrer">https://www.example.com/Pictures/thumbs/thumb.png</a> is resized in HTML or CSS from 148x100 to 68x46. Serving a scaled image could save 30.7KiB (78% reduction).</li> <li><a href="https://www.example.com/Pictures/thumb/thumb.png" target="_blank" rel="nofollow noopener noreferrer">https://www.example.com/Pictures/thumbs/thumb.png</a> is resized in HTML or CSS from 148x100 to 68x46. Serving a scaled image could save 30.7KiB (78% reduction).</li> <li><a href="https://www.example.com/Pictures/thumbs/0093.jpg" target="_blank" rel="nofollow noopener noreferrer">https://www.example.com/Pictures/thumbs/0093.jpg</a> is resized in HTML or CSS from 300x458 to 138x200. Serving a scaled image could save 28.9KiB (79% reduction).</li> </ul> </p> </div> </td> </tr> </table>'; $dom = new DOMDocument(); libxml_use_internal_errors(true); $dom->loadHTML($html); $xpath = new DOMXPath($dom); $result = []; foreach ($xpath->query('//tr/td/div//ul/li/a') as $a) { $result[] = [$a->nodeValue, preg_match('~to \K\d+x\d+~', $a->parentNode->nodeValue, $m) ? $m[0] : '']; } var_export($result);
Output for 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.18, 8.3.0 - 8.3.4, 8.3.6
array ( 0 => array ( 0 => 'https://www.example.com/Pictures/thumbs/0029.jpg', 1 => '123x200', ), 1 => array ( 0 => 'https://www.example.com/Pictures/thumbs/0133.jpg', 1 => '135x200', ), 2 => array ( 0 => 'https://www.example.com/Pictures/thumbs/0075.jpg', 1 => '176x200', ), 3 => array ( 0 => 'https://www.example.com/Pictures/thumbs/0057.jpg', 1 => '174x200', ), 4 => array ( 0 => 'https://www.example.com/Pictures/thumbs/thumb.png', 1 => '68x46', ), 5 => array ( 0 => 'https://www.example.com/Pictures/thumbs/thumb.png', 1 => '68x46', ), 6 => array ( 0 => 'https://www.example.com/Pictures/thumbs/thumb.png', 1 => '68x46', ), 7 => array ( 0 => 'https://www.example.com/Pictures/thumbs/thumb.png', 1 => '68x46', ), 8 => array ( 0 => 'https://www.example.com/Pictures/thumbs/0093.jpg', 1 => '138x200', ), )
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 array ( 0 => array ( 0 => 'https://www.example.com/Pictures/thumbs/0029.jpg', 1 => '123x200', ), 1 => array ( 0 => 'https://www.example.com/Pictures/thumbs/0133.jpg', 1 => '135x200', ), 2 => array ( 0 => 'https://www.example.com/Pictures/thumbs/0075.jpg', 1 => '176x200', ), 3 => array ( 0 => 'https://www.example.com/Pictures/thumbs/0057.jpg', 1 => '174x200', ), 4 => array ( 0 => 'https://www.example.com/Pictures/thumbs/thumb.png', 1 => '68x46', ), 5 => array ( 0 => 'https://www.example.com/Pictures/thumbs/thumb.png', 1 => '68x46', ), 6 => array ( 0 => 'https://www.example.com/Pictures/thumbs/thumb.png', 1 => '68x46', ), 7 => array ( 0 => 'https://www.example.com/Pictures/thumbs/thumb.png', 1 => '68x46', ), 8 => array ( 0 => 'https://www.example.com/Pictures/thumbs/0093.jpg', 1 => '138x200', ), )

preferences:
167.54 ms | 404 KiB | 182 Q