Scarass Scarass - 29 days ago 8
PHP Question

Pass input data to subarray of GET or POST

Is it possible to have some data in a sub array of

get
or
post
?

Say I want input values from user in
$_GET['values']['value']
, instead of
$_GET['value']
Or in post?

Answer

Yes, it's possible.

Instead of:

<input type="text" name="input_value" />

You can use:

<input type="text" name="inputs['input_value']" />

This way - php gets the inputs as an Array and the inputs_value is one of the keys in that array:

$_GET['inputs']['input_value'];

You can use the var_dump function to dump the $_GET and $_POST arrays to see their values:

var_dump($_GET);
var_dump($_POST);