PHP Add a domain name to the image in the editor _php tutorial

Source: Internet
Author: User
/**
* Replace the image in Fckedit to add a domain name
* @param string $content What to replace
* @param the name of the image to be added to the string $STRURL content
* @return String
* @eg
*/
function Replacepicurl ($content = null, $STRURL = null) {
if ($STRURL) {
Extracts the regular expression of the src of the image path and deposits the result in $matches
Preg_match_all ("/]+>/isu", $content, $matches);
$img = "";
if (!emptyempty ($matches)) {
Note that the above regular expression shows that the value of SRC 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;
}

To 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.html www.bkjia.com true http://www.bkjia.com/PHPjc/478768.html techarticle /** * Replace the picture in Fckedit add domain name * @param string $content What to replace * @param string $STRURL The name of the image to be added to the contents * @return String * @eg */ function R ...

  • 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.