PHP small function to replace HTML content

Source: Internet
Author: User
    1. /**

    2. * Replace HTML content
    3. * by bbs.it-home.org
    4. */
    5. function HTMLSP ($a)
    6. {
    7. if (Strpos ($a, ' < ', 0) ===false)
    8. {
    9. echo $a;
    10. }else
    11. {
    12. while (Strpos ($a, ' < ', 0) >=0)
    13. {
    14. if (Strpos ($a, ' < ', 0) ===false)
    15. Break

    16. $x 1 = strpos ($a, ' < ', 0);

    17. $x 2 = Strpos ($a, ' > ', 0);

    18. if ($x 2===false)//if special needs because the content may only <开始,没有> end

    19. $x 2 = strlen ($a);
    20. $t = substr ($a, $x 1, $x 2-$x 1 + 1);

    21. $a = Str_replace ($t, ", $a);

    22. }
    23. echo $a;
    24. }
    25. }

Copy Code

>>> you may be interested in the article: PHP string replacement function can replace multiple keywords PHP replacement file in the case of individual words in the Code PHP keyword replacement class (avoid duplicate substitution, retain and restore the original link) PHP implements keyword substitution with highlighted code PHP keyword substitution class instance code PHP content keyword replace function share PHP find, Replace the code in the string with the HTTP address to share PHP bulk replace the relative address as the absolute address of the instance code in the PHP replacement URL of the parameter variable in the code to replace the extra long text of the special characters in the PHP code to provide several PHP replacement line breaks using regular expressions to find and replace

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