Today, I wrote a function to retrieve the image inserted by fckeditor. _ PHP Tutorial

Source: Internet
Author: User
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...

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.