<?php

//任意编码转换到utf-8
function ToUtf8($data){
	if(is_array($data)){
		$output = array();
		foreach($data as $key => $value){
			 $k = @iconv(@mb_detect_encoding($key), 'UTF-8', $key);
			 $v = @iconv(@mb_detect_encoding($value), 'UTF-8', $value);
			 $output[$k] = $v;
		}
		return $output;
	}
	else{
		$encoding = @mb_detect_encoding($data);
		if($encoding == 'UTF-8'){
			return $data;
		}
		else{
			return @iconv($encoding, 'UTF-8', $data);
		}
	}
}

?>