Heim  >  Artikel  >  Backend-Entwicklung  >  今天写的一个获取fckeditor插入文章的图片函数,请高手指点一二。_PHP教程

今天写的一个获取fckeditor插入文章的图片函数,请高手指点一二。_PHP教程

WBOY
WBOYOriginal
2016-07-13 10:52:02923Durchsuche



问题
今天写的一个获取fckeditor插入文章的图片函数,请高手指点一二。
解决方法


在网上google了一阵,发现要把通过fckeditor插入文章中的图片取出来,网上写的都很麻烦,自己仔细研究了一下午,正则才刚刚开始学,写了下面这个函数,肯定还有很多不足,请各位指点一二。 /**

* 获取文章图片,能够获取fckeditor插入的图片

* @param int $aid 文章ID

* @return array $imagename 图片名称

**/

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;

}


复制代码



www.bkjia.comtruehttp://www.bkjia.com/PHPjc/632519.htmlTechArticle问题 今天写的一个获取fckeditor插入文章的图片函数,请高手指点一二。 解决方法 在网上google了一阵,发现要把通过fckeditor插入文章中的图...
Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn