php函数:解决数组转对象时数组内中文乱码问题

function to_urlencode(&$arr){//解决数组转对象时数组内中文乱码问题
	foreach($arr as $key => $value){
		if(is_array($value)){
			to_urlencode($arr[$key]);
		}else{
			$arr[$key] = urlencode($value);
		}
	}

 

$arr是二位数组的话,数组和对象的转换一般要执行以下操作:

to_urlencode($arr);
$arr_json = json_encode($arr);
$arr_json = urldecode($arr_json);

  

原文地址:https://www.cnblogs.com/cblx/p/8944727.html