Home  >  Article  >  Backend Development  >  Today I wrote a function to get pictures inserted into articles by fckeditor. Please give me some advice. _PHP Tutorial

Today I wrote a function to get pictures inserted into articles by fckeditor. Please give me some advice. _PHP Tutorial

WBOY
WBOYOriginal
2016-07-13 10:52:02927browse



Question
Today I wrote a function to get pictures inserted into articles by fckeditor. Please give me some advice.
Solution


I googled online for a while and found that it was very troublesome to take out the pictures inserted into the article through fckeditor. I studied it carefully for an afternoon and just started to learn the regular rules. I wrote the following function, but there must be many shortcomings. , please give me some advice. /**

* Get article pictures, and can get pictures inserted by fckeditor

* @param int $aid article ID

* @return array $imagename Image name

**/

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); //Here is the function to get a row of records

$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;

}


Copy code



www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/632519.htmlTechArticleQuestion Today I wrote a function to get the image of the article inserted by fckeditor. Please give me some advice. Solution: I googled online for a while and found that I need to insert the pictures into the article through fckeditor...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn