Sutlej Solutions

Extract all variables sent with POST , GET or PUT?

Extract all variables sent with POST , GET or PUT?

I am tired of extracting each variable posted by the FORM. weather its a $_GET or $_POST or $_PUT. I always wondered How can I extract all variables from request, especially $_POST?

Normally, I do




to see the contents in the $_POST variable. then extract them each one line at a time. which is , in some cases a big waste of time.

Easiest Method I found was very easy:


his code answers his question perfectly “How do I get all variables sent with POST?”. If security may not be an issue for your project, those who made php invented this function, so that it should be used. but carefully.

In production systems its never a good idea to extract all POST variables.

Another approach can be

function askForRequestedArguments(){
$getArray = ($tmp = filter_input_array(INPUT_GET)) ? $tmp : Array();
$postArray = ($tmp = filter_input_array(INPUT_POST)) ? $tmp : Array();
$allRequests = array_merge($getArray, $postArray);
return $allRequests;

But then you will have to loop thru the output and that will bring us back to original problem.

I have seen people doing


I am not sure why do they use @ , any thoughts?

How extract all variables from the superglobal arrays $_GET and $_POST can be transferred into normal variables?

If the register_globals setting has been deactivated (which should be the case), the GET and POST parameters can only be accessed via the superglobals of the same name ($_GET, $_POST). As soon as register_globals is switched on, however, a variable with the same name is created for each parameter. When calling up, for example, the variables “name” (with value “Alex”) and “age” (with value “25”) would be generated fully automatically. To simulate this behavior, the function extract() can be used on $_GET and / or $_POST. The function reads all key-value pairs and creates variables with the key as name and the value as variable content. Excrept from a blog

About the author...

#Freelancer #Journalist. Writes on #Economy, #Finance, #Constitution and #Technology. Develops #OpenSource #Software in #php #JavaScript. A #Foodie for Life!

View all posts by Rana Mansoor Akbar Khan

Your reactions

Add your comment

Fields marked with * are mandatory

© 2022 Sutlej Solutions

Why Sutlej Solutions

A single source solution provider for your all Web and Mobile App requirements. We understand your needs and provide simple and intelligent solutions. Our TV Gadget Reviews Blog and Custom Built Online Store as good examples of our excellent work

Need an Online Shop?

We provide full service Online Shop and Website Development and Maintenance Services.

Contact us Now: +923133359999

Business Hours

9.00pm – 6.00pm
9.00pm – 6.00pm
9.00pm – 6.00pm
9.00pm – 6.00pm
9.00pm – 6.00pm
9.00pm – 6.00pm
hire web development company