PHP implementation code for deleting HTMl tags _ PHP Tutorial

Source: Internet
Author: User
PHP implements code for deleting HTMl tags. Copy the code as follows: *** retrieve the html tag ** @ accesspublic * @ paramstringstr * @ returnstring ** functiondeletehtml ($ str) {$ strtrim ($ str); clear both sides of the string The code is as follows:


/**
* Retrieve html tags
*
* @ Access public
* @ Param string str
* @ Return string
*
*/
Function deletehtml ($ str ){
$ Str = trim ($ str); // clear spaces on both sides of the string
$ Str = strip_tags ($ str ,"

"); // Clear the html format using the built-in functions of php. Keep P tag
$ Str = preg_replace ("/\ t/", "", $ str); // use a regular expression to match the content to be replaced, such as space, line feed, and will be replaced with null.
$ Str = preg_replace ("/\ r \ n/", "", $ str );
$ Str = preg_replace ("/\ r/", "", $ str );
$ Str = preg_replace ("/\ n/", "", $ str );
$ Str = preg_replace ("//", "", $ str );
$ Str = preg_replace ("//", "", $ str); // matches spaces in html
Return trim ($ str); // return a string
}

The http://www.bkjia.com/PHPjc/327989.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/327989.htmlTechArticle code is as follows:/*** retrieve the html tag ** @ access public * @ param string str * @ return string **/function deletehtml ($ str) {$ str = trim ($ str); // clear both sides of the string...

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.