What's the way to quickly replace HTML with PHP?

Source: Internet
Author: User
Converts all of the HTML
Replace it with this.



...


Reply to discussion (solution)

How do you render it? (What does it mean?) What's the point? ), or do you want to change the

Or something like that?

How do you render it? (What does it mean?) What's the point? ), or do you want to change the

Or something like that?


Just for example, a tag like this is quick to replace
$html = "ABC,ABC,ABC,ABC,......"
Put all the "ABC" characters in the HTML
Replaced by
"1"
"2"
"3"
...

namely: $html = "4,......"

This replaces the contents of the tag, using JavaScript (jQuery).

This replaces the contents of the tag, using JavaScript (jQuery).
Well, I'll save it to the database after the replacement. So it's in the background PHP replacement AH.

$html = "ABC,ABC,ABC,ABC,......"; Echo preg_replace ('/abc/e ', ' + + $i ', $html);

$str = ' abc,abc,abcabc'; $i =1; $newstr = Preg_replace_callback (' |abc| ', function ($match) use (& $i) {return $ i++, $STR); Echo $newstr;

Two people are very good, preg_replace_callback seems to be able to connect string return ' str '. $i + +;


Can I connect preg_replace?
' str + + $i str ' will error

$html = "ABC,ABC,ABC,ABC,......"; Echo preg_replace ('/abc/e ', ' + + $i ', $html);

echo preg_replace ('/abc/e ', ' "str". + + $i ', $html);



I have always suspected that these 2 functions, but have not found you such a usage ....
To you!

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