public static function get_utf8($array, $type = 'utf-8') {
if (! empty ( $array )) {
if (is_array ( $array )) {
foreach ( $array as $k => $v ) {
if (is_array($v)) {
$arr [$k] = self::get_utf8 ( $v, $type );
} else {
if ($type == 'utf-8') {
if(CHAR=='utf-8'){
$arr [$k] = $v;//系统编码UTF8 需要返回UTF8编码,直接返回
} else{ $arr [$k] = iconv ( 'gb2312', 'utf-8', $v );//系统编码GB2312 需要返回UTF8编码,处理返回 }
} else {
if(CHAR=='gb2312'){
$arr [$k] = iconv ( 'utf-8', $type, $v );//系统编码UTF8 需要返回GB2312编码,处理返回
} else{ $arr [$k] =$v;//系统编码GB2312 需要返回GB2312编码,直接返回
}
}
}
}
} else {
if ($type == 'utf-8') {
if(CHAR=='utf-8'){
$arr =$array;//系统编码UTF8 需要返回UTF8编码,直接返回
} else{
$arr = iconv ( 'gb2312', 'utf-8', $array );//系统编码GB2312 需要返回UTF8编码,处理返回
}
} else {
if(CHAR=='gb2312'){
$arr = iconv ( 'utf-8', $type, $array );//系统编码UTF8 需要返回GB2312编码,处理返回
} else{
$arr =$array;//系统编码GB2312 需要返回GB2312编码,直接返回
}
}
}
}
return $arr;
}