PHP: Iterate all POST-Variables
Question by Guest | Last update on 2021-11-02 | Created on 2015-05-08
I am transmitting a dynamic form using POST to one of my PHP scripts in order to evaluate the data there.
Usually, each POST variable can be retrieved using $_POST['name'] in the script. However, in my case, I need a solution with which I can go through or loop over all POST variables existing without knowing their name or key, because they are created dynamically and can be different each time executing the script.
So, I need something like a foreach for the $_POST variable, which can be otherwise used for an array. The requirement is that I would like to have all values and key names receiving via POST. Is this possible somehow?
Related Topics
PHP: Write array to individual Variables
Tutorial | 0 Comments
Send Form Input as an Array to PHP Script
Tip | 0 Comments
PHP: Iterate UTF-8 String Character by Character
Question | 3 Answers
MySQL: Line Breaks in MySQL
Tip | 0 Comments
Android Programming: Receive Responce from HTTP POST Request
Tutorial | 0 Comments
jQuery: Send HTML5 Canvas to Server via Ajax
Tutorial | 0 Comments
Important Note
Please note: The contributions published on askingbox.com are contributions of users and should not substitute professional advice. They are not verified by independents and do not necessarily reflect the opinion of askingbox.com. Learn more.
Participate
Ask your own question or write your own article on askingbox.com. That’s how it’s done.
You can just apply "foreach" to $_POST, because $_POST is nothing more than an array containing all transmitted values.
Here is a small example:
Because $_POST is an associative array, it is possible to read out both, key names (here $key) and values (here $value) in this way, where the key is the name of the input field and the value is the corresponding content of the input field.
Last update on 2021-11-02 | Created on 2015-05-08