This article describes the use of PHP to remove HTML tags three ways, with the need for friends, refer to the next bar. Method 1, remove the desired tag directly. PHP functions are used: Str_replace, Htmlspecialchars, Strip_tags.
"," ", $str);//$str =htmlspecialchars ($STR); return strip_tags ($STR);}? >
The 2,php method has a strip_tags function to easily remove HTML tags. Echo strip_tags ("Hello World"); Remove HTML, XML, and PHP tags. For non-standard HTML code can also be correctly removed: Echo strip_tags ("\" >cftea "); Output Cftea Use the Strip_tags function to remove HTML tags.
Dreamdu. com '; Echo (Htmlspecialchars ($STR). " "); Echo (Strip_tags ($STR));? >
The 3,strtr method converts a specific character in a string to a function. Syntax Strtr (string,from,to) or STRTR (string,array) parameter description string1 required. Specifies the string to convert. From required (unless an array is used). Specifies the character to be changed. To required (unless an array is used). Specifies the character to change to. Array is required (unless you use from and to). An array in which the key is the original character and the value is the target character. Example 1:
Example 2:
"Hi", "World" = "Earth"); Echo strtr ("Hello World", $arr); > You may be interested in the article: PHP two ways to remove HTML tags PHP remove redundant HTML tags PHP with strip_tags complete removal of all HTML tags of the instance share PHP filter HTML tag function Strip_tags usage example (graphic) PHP Remove HTML tags and HTML tags in the code PHP HTML markup to remove the strip_tags and htmlspecialchars of the difference between the PHP delete the HTML tags in the function to remove the content of HTML Tag code extract HTML tag PHP code PHP regular filter HTML tags, spaces, line breaks, etc. code sample PHP Remove HTML tags get input plain text document STRIP_ tagsphp Make HTML tags auto-complete closed function code PHP implementation HTML tag Auto-complete code thinkphp HTML template Tag use method |