Method 1:
Directly remove the mark you want to remove
Copy CodeThe code is as follows:
Remove BR Mark
function strip ($STR)
{
$str =str_replace ("
"," ", $str);
$str =htmlspecialchars ($STR);
Return Strip_tags ($STR);
}
?>
Method 2.
PHP has a strip_tags function that makes it easy to 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
In PHP, you can use the Strip_tags function to remove HTML tags, as shown in the following example:
Copy CodeThe code is as follows:
$str = ' www
Dreamdu
. com ';
Echo (Htmlspecialchars ($STR).
”);
Echo (Strip_tags ($STR));
?>
Method 3.
The STRTR () function converts a specific character in a string.
Grammar
STRTR (String,from,to)
or
STRTR (String,array)
parameter |
description |
string1 |
required. Specifies the string to convert. |
from |
|
to |
|
Array |
Required (unless using from and to). An array in which the key is the original character and the value is the target character. |
Example 1:
Copy CodeThe code is as follows:
Echo strtr ("Hilla Warld", "ia", "eo");
?>
Example 2:
Copy CodeThe code is as follows:
$arr = Array ("Hello" = "Hi", "World" = "Earth");
Echo strtr ("Hello World", $arr);
?>
http://www.bkjia.com/PHPjc/327988.html www.bkjia.com true http://www.bkjia.com/PHPjc/327988.html techarticle Method 1: Directly remove the tag you want to remove the copy code code is as follows:? PHP//Remove BR tag function strip ($str) {$str =str_replace ("BR", "", $str);//$str = Htmlspecialchars ($STR); ....