How to convert PHP array to JSON array
This article mainly explains "how to convert PHP array into JSON array". The content of the article is simple and clear, and it is easy to learn and understand. Please follow Xiaobian's train of thought to study and learn "how to convert PHP array into JSON array".
How to change a PHP array into an JSON array:
1. The result is returned after the serialized character is transcoded from GBK to UTF-8 required by soap on the server:
$str = array ("body")
$serializeserialize_str =
Serialize ($str)
$res = iconv ("GBK", "UTF-8")
, $serialize_str)
Return $res
two。 After taking the result on the client side, convert the UTF-8 to the GBK required by the page, and then de-serialize and print the array to be a normal array without Chinese garbled code:
$iconviconv_str = iconv
("UTF-8", "GBK", $res)
$arr = unserialize
($iconv_str)
Var_dump ($arr)
Thank you for your reading, the above is the content of "how to convert PHP array into JSON array". After the study of this article, I believe you have a deeper understanding of how to convert PHP array into JSON array, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!