- print_r: documentation ( source)
- preg_match_all: documentation ( source)
<?php
$re = "/(media|images)(.*?)(.jpg|.jpeg|.png)/";
$str = 'images/test/test-1.png" alt="test-1" /></a><a href="/test-2" title="test 2"><img src="/images/test/test2.png" alt="test2" /></a> <a href="/test-3" title="Cruises in Croatia"><img src="/images/EET/test-3.png';
preg_match_all($re,$str,$matches );
print_r($matches);