Can base64_encode be used for arrays? If not, how can I transmit an array using base64_encode? What should I do?

Source: Internet
Author: User
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 );

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.