Php adds domain names to images in the editor

Source: Internet
Author: User
How does php add domain names to images in the editor? /*** Replace the image in fckedit with the domain name * @ paramstring $ content the content to be replaced * @ paramstring $ the domain name to be added to the image in the strUrl content * @ returnstring * @ eg php to the editor adding domain names to images in

?

/*** Replace the image in fckedit with the domain name * @ param string $ content the content to be replaced * @ param string $ the domain name to be added to the image in the strUrl content * @ return string * @ eg */function replacePicUrl ($ content = null, $ strUrl = null) {if ($ strUrl) {// extract the src regular expression of the image path and save the result to $ matches preg_match_all ("/] +>/isU ", $ content, $ matches); $ img = ""; if (! Empty ($ matches) {// note that the above regular expression indicates that the src value is placed in the third of the array $ img = $ matches [2];} else {$ img = "";} if (! Empty ($ img) {$ patterns = array (); $ replacements = array (); foreach ($ img as $ imgItem) {$ final_imgUrl = $ strUrl. $ imgItem; $ replacements [] = $ final_imgUrl; $ img_new = "/". preg_replace ("// I", "\/", $ imgItem ). "/"; $ patterns [] = $ img_new;} // sort the array by key ($ patterns); ksort ($ replacements ); // replace content $ vote_content = preg_replace ($ patterns, $ replacements, $ content); return $ vote_content;} else {return $ content ;}}

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.