Can base64_encode be used for arrays? If not, how can I transmit an array using base64_encode? What should I do? Can base64_encode be used for arrays? If not, how can I transmit an array using base64_encode? What should I do?
Reply to discussion (solution)
No!
An array is a struct. different languages implement different methods.
Therefore, it is necessary to convert the format string that can be recognized by the big family before transmission.
Serialize)
Php can use json or xml for other languages (including php)
It is better to serialize the array and use the serialize () function.
How to transfer cross-language?
It is better to serialize the array and use the serialize () function.
Convert json_encode into a json string and then base64_encode.
After receiving the message, first base64_decode and then json_decode to obtain the array.
$ Arr = array (1, 2, 4); $ str = base64_encode (json_encode ($ arr); echo $ str; $ data = json_decode (base64_decode ($ str), true ); print_r ($ data );