Works:
$str = "http://element-bmw.ru/wp-content/uploads/2017/01/323e33885d8518e1eddecde0a54a18b7-702x336.jpg <br> http://element-bmw.ru/wp-content/uploads/2017/01/auto_parts_volkswagen_golf_3-768x450.jpg"; $str2 = preg_replace('/http:\/\/(.*?)\.(jpg|jpeg|png|gif|bmp)/i','//site.ru/misc/img.php?url=http://$1.$2',$str); echo '<pre>'.print_r([$str,$str2],TRUE).'</pre>'; Does not work:
$str = "http://rambler.ru <br> http://element-bmw.ru/wp-content/uploads/2017/01/323e33885d8518e1eddecde0a54a18b7-702x336.jpg <br> http://element-bmw.ru/wp-content/uploads/2017/01/auto_parts_volkswagen_golf_3-768x450.jpg"; $str2 = preg_replace('/http:\/\/(.*?)\.(jpg|jpeg|png|gif|bmp)/i','//site.ru/misc/img.php?url=http://$1.$2',$str); echo '<pre>'.print_r([$str,$str2],TRUE).'</pre>'; With regulars on you, I count on your help.
httpto the first occurrence of the extension of the image falls into the regular calendar in the first case, this is just the first link (for it is in the picture). In the second case, these are two links in a row. - teran