Home >Backend Development >PHP Tutorial >Share tips for turning PHP arrays into JSON arrays_PHP Tutorial
Today, we will introduce to you a specific implementation method of
PHP array into JSON array:
1. On the server side The serialized characters are converted from GBK to UTF-8 required by soap and the result is returned:
2. Get the result on the client side Then convert UTF-8 to GBK required by the page, and then deserialize and print the array to be a normal array without Chinese garbled characters:
<ol class="dp-xml"> <li class="alt"><span><span>$</span><span class="attribute-value">iconv</span><span class="attribute">iconv_str</span><span> = iconv<br>("UTF-8","GBK",$res); </span></span></li> <li> <span>$</span><span class="attribute">arr</span><span> = </span><span class="attribute-value">unserialize<br></span><span>($iconv_str); </span> </li> <li class="alt"><span>var_dump($arr); </span></li> </ol>
The above code example is all about turning a PHP array into a JSON array. implementation process.