This article mainly introduces the usage of php to submit the post array parameters, and analyzes the related skills of php to submit parameters using post in combination with examples, for more information about how to use php to submit post array parameters, see the example in this article. We will share this with you for your reference. The details are as follows:
First, to transfer an array from a page to server a in php, multiple spaces on the page must have the same name, and the name must be "aa []", note that you need to add an array symbol so that it can be obtained on server.
The code is as follows:
$ _ POST [aa]
The result is an array.
A deeper problem is that, if I need to process the parameters in post and then send them to another server, how should I pass the aa parameter?
If no processing is done, after the post request is assembled, server B will always get the Array and cannot get the actual value.
The solution is: now server a is serialized and then deserialized after server B receives the request. In this way, the deserialization value is an array, which is the same as that obtained in Section.
The code is 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 deserialization is successful.
$bb = $_POST["aa"];$bb = str_replace("\\", '', $bb);var_dump(unserialize($a));
Well, this is the result you want.
Of course, another problem is that you can directly pass the array value to a space on the page and submit it to the server. In this case, serialization and deserialization are also required.
Page
var_dump(base64_decode(unserialize({1}
POST['post_data'])));
I don't know what the function of adding this base64_encode seems to be for Chinese encoding?
I hope this article will help you with php programming.