3v4l.org

run code in 300+ PHP versions simultaneously
<?php $string = '<img src="https://example.com/123456789/300.jpg?key=abcdefg" /> <img src="https://example.com/123456789/600.jpg?key=abcdefg" /> <img src="https://example.com/123456789/900.jpg?key=abcdefg" /> <img src="https://example.com/123456789/1200.jpg?key=abcdefg" />'; $dom = new DOMDocument; $dom->loadHTML($string); $images = $dom->getElementsByTagName('img'); foreach($images as $image) { echo $image->getAttribute('src') . PHP_EOL; }
Output for 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.30, 8.2.0 - 8.2.25, 8.3.0 - 8.3.13
https://example.com/123456789/300.jpg?key=abcdefg https://example.com/123456789/600.jpg?key=abcdefg https://example.com/123456789/900.jpg?key=abcdefg https://example.com/123456789/1200.jpg?key=abcdefg

preferences:
86.35 ms | 407 KiB | 5 Q