This article mainly introduces the use of PHP to submit post array parameters, the interest of friends under the reference, I hope to be helpful to everyone.
The code is as follows:
$_POST[AA]
Gets the array.
The deeper question is, suppose I now need to process the parameters in the post, and then pass it on to the other server, what should I do with the parameter AA?
If you do not do any processing, after assembling the POST request, Server B gets the only array, unable to fetch the actual value.
Now the solution is: server-side A is now serialized, and then deserialized after server-side B is received. The deserialized value is then an array, and the same is obtained for the A segment.
Serialization of
Copy the Code code as follows:
$_post["AA"] =serialize ($_post[aa]);
Deserialization
$a = "a:2:{i:0;s:1:\" 1\ "; i:1;s:1:\" 2\ ";}"; Var_dump (Unserialize ($a));
What is the result:
Array (2) {[0]=> string (1) "1" [1]=> string (1) "2"}
The serialized parameters obtained in post are added with escape characters, which need to be removed before they can be deserialized successfully.
$BB = $_post["AA"]; $bb = str_replace ("\ \", "", $BB); Var_dump (Unserialize ($a));
Well, that's the result you want.
Of course, another problem is that you can simply pass the array value to a space on the page and submit it to the server. This situation also requires serialization and deserialization.
Page
<input type= "hidden" name= "AA" value= "<?php Echo Base64_encode (Serialize ($array));? > "/>var_dump (Base64_decode (unserialize (<pre class=" html "name=" code ">{1}</pre><br>post[" Post_data ']));
Summary: The above is the entire content of this article, I hope to be able to help you learn.