php去除空格和换行

php去除空格和换行函数

function trimall($str){
$qian=array(” “,“ ”,“\t”,“\n”,“\r”);
return str_replace($qian, , $str);
}
实例如下:
<meta name="description" content="<?php
if(is_home()||is_category()||is_tag()){
    echo  iconv('GB2312','UTF-8','本站提供时尚,美食,家居,装修,阁楼杂志,美女写真,军事,财经,人物周刊等杂志下载');
}
if(is_single()){
    if (has_excerpt()) {
        echo $description = get_the_excerpt(); 
    }else {
        function trimall($str)
        {
            $qian = array(" ", " ", "\t", "\n", "\r");
            return str_replace($qian, '', $str);
        }
        $str = mb_strimwidth(strip_tags(apply_filters(‘the_content’, $post->post_content)), 0, 350,””);
        echo trimall($str);
    }
}
?>
">
Posted in PHP