$message='';
$pattern='/\[img=(\d{1,4})[x|\,](\d{1,4})\]\s*([^\[\<\r\n]+?)\s*\[\/img\]/is';
$message = preg_replace($pattern, '<img src="$3" width="$1" height="$2">', $message);
echo $message;
替换后输出:<img src="http://static.yimiyuan.com/food/article/100396/11.jpg" width="600" height="379">
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货