龙盟编程博客 | 无障碍搜索 | 云盘搜索神器
快速搜索
主页 > web编程 > php编程 >

php 过滤带有html标签的内容

时间:2014-10-19 02:48来源:网络整理 作者:网络 点击:
分享到:
过滤带有html标签的内容 [代码片段(17行)]
function html2text($str){
    $str    =   trim($str);
    $str = preg_replace("/||<!--(.*)-->/isU","",$str);
    $alltext = "";
    $start = 1;
    for($i=0;$i31){
        $alltext .= $str[$i];
            }
        }
    }
    $alltext = str_replace(" "," ",$alltext);
    $alltext = preg_replace("/&amp;([^;&amp;]*)(;|&amp;)/","",$alltext);
    $alltext = preg_replace("/[ ]+/s"," ",$alltext);
    $alltext    =   htmlspecialchars($alltext,ENT_QUOTES);
    return $alltext;
}
//该片段来自于http://outofmemory.cn
精彩图集

赞助商链接