<?php header("Content-type:text/html;charset=utf-8"); $str = '<p> <img src="http://localhost/js/umeditor/php/upload/20160730/146988951333.jpg" _src="http://localhost/js/umeditor/php/upload/20160730/146988951333.jpg"/></p>' . '<p><img src="http://localhost/js/umeditor/php/upload/20160730/14698896174705.jpg" _src="http://localhost/js/umeditor/php/upload/20160730/14698896174705.jpg"/></p>'; $preg="/<[img|IMG].*?src=[\'|\"](.*?(?:[\.gif|\.jpg]))[\'|\"].*?[\/]?>/";
preg_match_all($preg, $str, $imgArr);
print_r($imgArr[1]);
//================以下是获取图片类型==================
$url = 'http://img1.epetbar.com/2015-11/06/16/8d1d14dba810f0ec291ee937b362e63e.png.jpg';
$img = substr($url, strrpos($url, '/')+1);
echo $img;echo '<br/>';
//获取图片后缀
$type = substr($url, strrpos($url, '.'));
echo $type;echo '<br/>';
//获取图片名(不包括后缀)
$name = substr($img, 0, strrpos($img, '.'));
echo $name;