Home >Backend Development >PHP Tutorial >PHP implementation code to delete HTMl tag_PHP tutorial
"); //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
}