Home  >  Article  >  Backend Development  >  PHP implementation code to delete HTMl tag_PHP tutorial

PHP implementation code to delete HTMl tag_PHP tutorial

WBOY
WBOYOriginal
2016-07-21 15:01:26773browse

Copy code The code is as follows:

/**
* Take out the html tag
*
* @access public
* @param string str
* @return string
*
*/
function deletehtml($str) {
$str = trim($str); //Clear the spaces on both sides of the string
$str = strip_tags($str,"

"); //Use the function that comes with PHP to clear the html format. Keep the P tag
$str = preg_replace("/t/","",$str); //Use regular expressions to match the content that needs to be replaced, such as spaces, newlines, and replace them with nothing.
$str = preg_replace("/rn/","",$str);
$str = preg_replace("/r/","",$str);
$str = preg_replace( "/n/","",$str);
$str = preg_replace("/ /","",$str);
$str = preg_replace("/ /","",$ str); // Match spaces in html
return trim($str); // Return string
}

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/327989.htmlTechArticleCopy the code The code is as follows: /*** Take out the html tag * * @access public * @param string str * @return string **/ function deletehtml($str) { $str = trim ($str); //Clear both sides of the string...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn