在网上google了一阵,发现要把通过fckeditor插入文章中的图片取出来,网上写的都很麻烦,自己仔细研究了一下午,正则才刚刚开始学,写了下面这个函数,肯定还有很多不足,请各位指点一二。
-
-
-
-
-
-
-
-
-
-
- function get_image_article ($aid) {
-
- global $db,$dbpre;
-
- $aid = intval($aid);
-
- $data = array();
-
- $sql = "select aid,acontent from {$dbpre}article where `aid`='{$aid}'";
-
- $data = $db->get_one_record($sql);
-
- $imagename = array();
-
- preg_match_all('/input type="image" (.*) />/',$data,$arr);
-
- foreach ($arr as $key => $val) {
-
- if ($key == 1) {
-
- foreach ($val as $k => $v) {
-
- $imagename[] = substr($v,strrpos($v,"/")+1,-1);
-
- }
- }
- }
- unset ($aid,$data,$sql,$arr);
-
- return $imagename;
- }