PHP filter string Function _php Tutorial

Source: Internet
Author: User
Share a PHP filter string function with the following code:

function striphtml ($string) {$pattern =array ("' Si '," '
 
  
   
  ]*?>.*? ') Si ",  " ' <[\/\!] *? [^<>]*?> ' si ', '  ' ([\ r \ n]) [\s]+ ' ",  " ' & (quot| #34); ' I ",  " ' & (amp| #38); ' I ",  " ' & (lt| #60); ' I ",  " ' & (gt| #62); ' I ",  " ' & (nbsp| #160); ' I ",  " ' & (iexcl| #161); ' I ",  " ' & (cent| #162); ' I ",  " ' & (pound| #163); ' I ",  " ' & (copy| #169); ' I ",  " ' "(\d+); E "); $replace =array (", "," \\1 "," "," & "," < "," > "," ", Chr (161), Chr (162), Chr (163), Chr (169)," Chr (\\1) "); r Eturn preg_replace ($pattern, $replace, $str);}
 
  

Articles you may be interested in

    • Some of the powerful string handling functions that PHP has forgotten
    • PHP's most accurate string-length intercept function
    • PHP string substitution function str_replace faster than preg_replace
    • String processing function in PHP (string Functions) Full summary
    • PHP string Escape function (Addslashes,stripslashes) detailed
    • JS array to string, JS string to array method summary
    • PHP extracts numbers in a string
    • PHP generates consecutive numbers (Letters) array function range () analysis, PHP lottery program function

http://www.bkjia.com/PHPjc/764104.html www.bkjia.com true http://www.bkjia.com/PHPjc/764104.html techarticle Share a PHP filter string function with the following code: function striphtml ($string) {$pattern =array ("' script[^]*?. *?/script ' si ', ' style[^]*? *?/style ' si ', "' [\/\!] *? [^]*?' Si " ...

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