PHP 正则取图片地址

//取第一张图
$imgpreg = '/<\s*img\s+[^>]*?src\s*=\s*(\'|\")(.*?)\\1[^>]*?\/?\s*>/i';
preg_match($imgpreg,$info['picture'],$arraypic);
if(count($arraypic) >= 2){
    $info['good_pic'] = $arraypic[count($arraypic)-1];
}elseif(count($arraypic) == 1){
    $info['good_pic'] = $arraypic[0];
}else{
    $info['good_pic'] = '';
}

//图片列表
preg_match_all($imgpreg,$info['picture'],$piclist);
if(count($piclist) >= 2){
    $info['piclist'] = $piclist[count($piclist)-1];
}elseif(count($piclist) == 1){
    $info['piclist'] = $piclist[0];
}else{
    $info['piclist'] = '';
}