Can the Str_replace function in PHP replace 3 at the same time?

Source: Internet
Author: User
Can the Str_replace function in PHP replace 3 at a time?
$content = Str_replace (' #p # subtitle #e# ', ', $body);
$content = Str_replace (' See next Page ', ' ', $body);
$content = Str_replace ('/uploads ', ' http://www.****.com/uploads ', $body);

Guys, I want the output of the $body read content, while replacing the inside of the "#p # subtitle #e#" "' See next Page" "/uploads"

How does it come true, please? Now only the last statement can be replaced, and 3 cannot be replaced at the same time
------to solve the idea----------------------
$body =<<< ' TXT '
Guys, I want the output of the $body read content, while replacing the inside of the "#p # subtitle #e#" " ' see next Page" "/uploads"
TXT;

$body = Str_replace (' #p # subtitle #e# ', ', $body);
$body = Str_replace (' See next Page ', ' ', $body);
$body = Str_replace ('/uploads ', ' http://www.****.com/uploads ', $body);
Echo $body;
It's more straightforward to write.
Body =<<< ' TXT '
Guys, I want the output of the $body read content, while replacing the inside of the "#p # subtitle #e#" " ' see next Page" "/uploads"
TXT;
$p = Array (' #p # subtitle #e# ', ' see next Page ', '/uploads ');
$r = Array (' ', ' ', ' http://www.****.com/uploads ');
Echo Str_replace ($p, $r, $body);

------to solve the idea----------------------

Header ("content-type:text/html; Charset=utf-8 ");
$body = << <>
#p # subtitle #e#
Take a look at the next page
/uploads
BODY;
$content = Str_replace (' #p # subtitle #e# ', ', $body);
$content = Str_replace (' See next Page ', ' ', $body);
$content = Str_replace ('/uploads ', ' http://www.****.com/uploads ', $body);
echo "Pre-replace content:". "
" . $body. "
" . " ";
$arr _orignal_content = Array (' #p # subtitle #e# ', ' see next Page ', '/uploads ');
$arr _replace_content = Array (' ', ' ', ' http://www.baidu.com/uploads ');
$body = Str_replace ($arr _orignal_content, $arr _replace_content, $body);
echo "Replaced content:". "
" . $body;

------to solve the idea----------------------
The upstairs are all positive solutions.
------to solve the idea----------------------
You can use the regular, the three to spell a regular can
------to solve the idea----------------------
After the first replacement, do not use the $body, but with $content in the back of the replacement.


$content = Str_replace (' #p # subtitle #e# ', ', $body);
$content = Str_replace (' See next Page ', ' ', $content);
$content = Str_replace ('/uploads ', ' http://www.****.com/uploads ', $content);
  • Related Article

    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.