Array | | ( | | [0] => Array | | ( | | [0] => <img src="data/attachment/portal/CJ/201306/26/2013062616163520c381b.jpg" > | | [1] => <img src="data/attachment/portal/CJ/201306/26/2013062616163523f0gs6.jpg" > | | [2] => <img src="data/attachment/portal/CJ/201306/26/2013062616163526f2m4r.jpg" > | | ) | |
| | [1] => Array | | ( | | [0] => data/attachment/portal/CJ/201306/26/2013062616163520c381b.jpg | | [1] => data/attachment/portal/CJ/201306/26/2013062616163523f0gs6.jpg | | [2] => data/attachment/portal/CJ/201306/26/2013062616163526f2m4r.jpg | | ) | |
| | ) |
上面是用preg_match_all 加入正则表达式从内容中得到的图片路径数组,但应该怎么写才能把
[1] => Array | | ( | | [0] => data/attachment/portal/CJ/201306/26/2013062616163520c381b.jpg | | [1] => data/attachment/portal/CJ/201306/26/2013062616163523f0gs6.jpg | | [2] => data/attachment/portal/CJ/201306/26/2013062616163526f2m4r.jpg | | ) |
这里得到的路径依次循环上传到服务器呀!
foreach($picarr[1] as $key => $v){
$v = str_replace("data/attachment/portal/","",$v);
$ym = basename($v);
$hc = substr(strrchr($ym, '.'), 1);
$sql="INSERT INTO {$tablepre}portal_attachment (`attachid`, `uid`, `dateline`, `filename`, `filetype`, `filesize`, `attachment`, `isimage`, `thumb`, `remote`, `aid`)VALUES ('', '129', '$posttime', '$ym', '$hc', '', '$v', '1', '$thumb', '0', '$aid')";
$db->query($sql);
}
上面是我写的foreach循环上传数据库,但是却引用不了变量。。。。
|
|
|