Today, I wrote a function to retrieve the image inserted by fckeditor .. Question: I wrote a function today to get the picture of the inserted articles in fckeditor. please give me some advice. After a while on the Internet, I found that I had to insert the diagram in the article through fckeditor.
Today, I wrote a function to retrieve the image inserted by fckeditor.
Solution
After a while on the Internet, google found that it was very troublesome to write images inserted in articles through fckeditor. after studying the regular expressions for one afternoon, I just started learning, after writing the following function, you must have many shortcomings. please give me some advice. /**
* Get the article image and get the picture 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); // The function used to obtain 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;
}
Today, I wrote a function to get an image inserted by fckeditor. After a while on the Internet, I found that I needed to insert the diagram in the article through fckeditor...