This paper analyzes the use of PHP to submit post array parameters. Share to everyone for your reference, as follows:
First of all, PHP in order to transfer from the page array to server A, multiple spaces on the page with the same name, and for the name is required, that is Name= "aa[]", notice here to add an array of symbols, so that the server can be taken to a
Copy the Code code 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
Var_dump (Base64_decode (Unserialize ({1}
post[' Post_data ')));
I do not know what the effect of adding this base64_encode, seems to be to the Chinese code it?
I hope this article is helpful to you in PHP programming.
The above describes the PHP submit post array parameter analysis, including the aspects of the content, I hope that the PHP tutorial interested in a friend helpful.