php function: solve the problem of Chinese garbled characters in the array when the array is converted to an object

function to_urlencode(&$arr){//Solve the problem of Chinese garbled characters in the array when the array is converted to an object
	foreach($arr as $key => $value){
		if(is_array($value)){
			to_urlencode($arr[$key]);
		}else{
			$arr[$key] = urlencode($value);
		}
	}

 

If $arr is a two-digit array, the conversion between array and object generally requires the following operations:

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

  

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324829123&siteId=291194637