JTBC(php版):过滤HTML代码的函数
作者:我就是个世界
发表于:2011-01-09
把以下代码添加到: common/incfiles/function.inc.php
[code]
function ii_RemoveHTML($str)
{
$a = strip_tags($str);
if (!ii_isnull($a)){
$a = str_replace(VbCrLf, "", $a);
$a = str_replace(vbNewLine, "", $a);
$a = str_replace(" ", "", $a);
$a = str_replace(" ", "", $a);
$a = str_replace(" ", "", $a);
$a = str_replace(chr(13), "", $a);
$a = str_replace(chr(10), "", $a);
$a = str_replace(" ", "", $a); }
return $a;
}
[/code]
[b]用法:[/b][separator]
[code]{$=ii_left(ii_RemoveHTML(mm_encode_content($GLOBALS['RST_content'], '{$cttype}')), 100)}[/code]
[quote]解释:
其中mm_encode_content($GLOBALS['RST_content'], '{$cttype}')负责提取内容
ii_RemoveHTML负责去处HTML标记(如空格,换行等等),ii_left($string, $len, $type = 0)负责截取内容字数
[/quote]
[code]
function ii_RemoveHTML($str)
{
$a = strip_tags($str);
if (!ii_isnull($a)){
$a = str_replace(VbCrLf, "", $a);
$a = str_replace(vbNewLine, "", $a);
$a = str_replace(" ", "", $a);
$a = str_replace(" ", "", $a);
$a = str_replace(" ", "", $a);
$a = str_replace(chr(13), "", $a);
$a = str_replace(chr(10), "", $a);
$a = str_replace(" ", "", $a); }
return $a;
}
[/code]
[b]用法:[/b][separator]
[code]{$=ii_left(ii_RemoveHTML(mm_encode_content($GLOBALS['RST_content'], '{$cttype}')), 100)}[/code]
[quote]解释:
其中mm_encode_content($GLOBALS['RST_content'], '{$cttype}')负责提取内容
ii_RemoveHTML负责去处HTML标记(如空格,换行等等),ii_left($string, $len, $type = 0)负责截取内容字数
[/quote]
请发表您的评论