首页 > 其他 > 详细

字符内容转换

时间:2014-11-19 23:36:44      阅读:275      评论:0      收藏:0      [点我收藏+]

<?php
// getallheaders();
// gethostbyname()
//字符内容转换
function unhtml($content){
    $content=htmlspecialchars($content);
    $content=str_replace(chr(13), "<br>", $content);
    $content=str_replace(chr(32), "&nbsp", $content);
    $content=str_replace("[_[", "<", $content);
    $content=str_replace(")_)", ">", $content);
    $content=str_replace("|_|", "&nbsp", $content);
    return trim($content);
}
//控制文本数据输出
function msubstr($str,$start,$len){
    $strlen=$start+$len;
    $tmp=0;
    for ($i=0; $i <$strlen ; $i++) {
        //大于0xa0表示字符串为汉字
        if(ord(substr($str,$i,1))>0xa0){
            //是汉字,取2个字符给到变量

            $tmp.=substr($str,$i,2);
            $i++;
        }else{
            //不是汉字,取一个字符
            $tmp.=substr($str, $i,1);
        }
    }
    return $tmp;
}

字符内容转换

原文:http://www.cnblogs.com/lemon66/p/4109274.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!