问题
今天写的一个获取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;
}
复制代码
每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号