3v4l.org

run code in 300+ PHP versions simultaneously
<?php $str = "This is one string with this picture pic1.jpg and here there's another one pic2.png for example"; $pat = '/\w+\d\.[a-zA-Z]{3}/'; $arrImg = null; if (preg_match_all( $pat, $str, $matches, PREG_PATTERN_ORDER )) { $arrImg = array_pop($matches); print_r($arrImg); } else { echo "no matches"; }

preferences:
27.68 ms | 406 KiB | 5 Q