Can base64_encode be used in arrays? If not, my little brother, I want to send an array with Base64_encode? What to do with it

Source: Internet
Author: User
Can base64_encode be used in arrays? If not, I want to send an array with Base64_encode? What should I do?
Can base64_encode be used in arrays? If not, I want to send an array with Base64_encode? What should I do?
------to solve the idea----------------------
No!
An array is a struct, and the methods that are implemented in different languages are different.
So it should be converted into a format string that can be recognized by everyone to transmit
PHP available for PHP serialization (serialize)
PHP is available in JSON or XML for other languages (including PHP)
------to solve the idea----------------------
First use Json_encode to convert to a JSON-formatted string, and then Base64_encode.
Once received, Base64_decode first, then json_decode to get the array.


$arr = Array (1,2,3,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.