3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $bigKml = "<br><img src='files/bagel.png'><br><br>"; $imgPattern = "/<img src=.*?>/"; preg_match($imgPattern, $bigKml, $imageTags); print_r($imageTags); foreach($imageTags as $imageTag) { $urlPattern = "/'([^']*)'/"; preg_match($urlPattern, $imageTag, $oldUrls); $oldUrl = $oldUrls[1]; //the second element contains the match without the quotes print_r($oldUrl); $newUrl = "/var/www/resources/" + $oldUrl; print_r($newUrl); } ?>
Output for 7.1.0 - 7.3.0rc4
Array ( [0] => <img src='files/bagel.png'> ) files/bagel.png Warning: A non-numeric value encountered in /in/QNPrQ on line 15 Warning: A non-numeric value encountered in /in/QNPrQ on line 15 0
Output for 4.3.0 - 7.0.20
Array ( [0] => <img src='files/bagel.png'> ) files/bagel.png0