复制代码 代码如下:
$word = '
111 22
中国人';//取整个图片代码
preg_match('/]*?src/s*=/s*(/'|/")(.*?)//1[^>]*?//?/s*>/i',$word,$matches);
echo $matches[0];//结果:
$word = '
111 22
中国人';//取width
preg_match('//i',$word,$matches);
echo $matches[1];
//取height
preg_match('//i',$word,$matches);
echo $matches[1];
//取src
preg_match('//i',$word,$matches);
echo $matches[1];
$str = '
111 22
中国人31313 224344
1212121';//改变src属性(此处将原来的src="/upload/images/bbb.jpg"改变为src="/upload/_thumbs/Images/bbb.jpg")
print preg_replace('/()/i',"/${1}_thumbs/Images//${3}",$str);
print preg_replace('/(/i',"/${1} /${2}_thumbs/Images//${3}>",$str);
?>



