Php adds a domain name to the image 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 * functionr /* *
* Replace the image in fckedit with the domain name
* @ Param string $ 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 regular expression src of the image path and save the result to $ matches.
Preg_match_all ("/] +>/isU", $ content, $ matches );
$ Img = "";
If (! Emptyempty ($ 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 (! Emptyempty ($ 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
Ksort ($ patterns );
Ksort ($ replacements );
// Replace content
$ Vote_content = preg_replace ($ patterns, $ replacements, $ content );
Return $ vote_content;
} Else {
Return $ content;
}
} Else {
Return $ content;
}
}
Http://www.bkjia.com/PHPjc/478768.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/478768.htmlTechArticle/** * 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 r...