PHP removes the implementation code for the HTMl tag

  • 2020-06-23 00:01:26
  • OfStack


/**
 *  Take out the html The label 
 * 
 * @access public
 * @param string str
 * @return string
 * 
 */
function deletehtml($str) {
    $str = trim($str); // Clears the Spaces on both sides of the string 
    $str = strip_tags($str,"<p>"); // using php Built-in function cleanup html Format. keep P The label 
    $str = preg_replace("/\t/","",$str); // Use regular expressions to match the content that needs to be replaced, such as Spaces, line feeds, and will be replaced with empty. 
    $str = preg_replace("/\r\n/","",$str); 
    $str = preg_replace("/\r/","",$str); 
    $str = preg_replace("/\n/","",$str); 
    $str = preg_replace("/ /","",$str);
    $str = preg_replace("/&nbsp; /","",$str);  // matching html The Spaces in the 
    return trim($str); // Return string 
}

Related articles: