function get_imgurl($txt){
if(!isset($txt)){
die ('缺少參數');
//return '';
}
else{
preg_match_all ("/<(img|IMG)(.*)(src|SRC)=[\"|'|]{0,}([h|\/].*(jpg|JPG|gif|GIF|png|PNG))[\"|'|\s]{0,}/isU",$txt,$out);
return $out[4];
}
}
需要注意的是,FCKeditor提交過來的值,根據PHP環境不同,可能被增加反斜槓,需要用stripslashes去掉。本人用了萬網的M3空間,就遇到了這樣的問題。
$txt = stripslashes($_POST['FCKeditor1']);
$txtimgurl = get_imgurl($txt);//獲得文本框中圖片的路徑
$txtimgurl = implode(',',$txtimgurl);