项目中转码用的方法

//转码
        public  function iconv2utf8($Result) {
            $Row = array ();
            $key1 = array_keys ( $Result );
            $key2 = array_keys ( $Result [$key1 [0]] );
            for($i = 0; $i < count ( $key1 ); $i ++) {
                for($j = 0; $j < count ( $key2 ); $j ++) {
                    $Row [$key1 [$i]] [$key2 [$j]] = iconv ( 'gbk', 'utf-8//IGNORE', $Result [$key1 [$i]] [$key2 [$j]] );
                }
            }
            return $Row;
        }
        
        
        public function icon1utf8($Result){
            
            if(is_string($Result)) return iconv ( 'gbk', 'utf-8//IGNORE', $Result);
            foreach($Result as $k=>$v){
                if(is_array($v)) 
                    $Result[$k] = $this->icon1utf8($v);
                else
                    $Result[$k] = iconv ( 'gbk', 'utf-8//IGNORE', $v);
            }
            return $Result;    
        }
原文地址:https://www.cnblogs.com/chenchenphp/p/6427584.html