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

PHP implementation code to delete HTMl tag_PHP tutorial

WBOY
Release: 2016-07-21 15:01:26
Original
835 people have browsed it

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...
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template