php array to a json Chinese garbled solution

Urlencode performed for each element in the array () then with transcoding json_encode () can be converted to json, using decoding of json_decode ()

Example:

foreach ($ result as $ keys => $ value) // two-dimensional array comprising Chinese $ result turn json, eleven element array using urlencode internal conversion can not guarantee Chinese distortion {foreach ($ value as $ key => $ column) {$ testJSON [$ keys] [$ key] = urlencode ($ column);}} var_dump (json_encode ($ testJSON)); // Switch json $ result = urldecode (json_encode ($ testJSON)); // back to the array

Guess you like

Origin www.cnblogs.com/xiaogou/p/11655551.html