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);