1
Following this post I created the following html by passing arrays as an input element attribute:
...
<input type="text" name="setValues[cardExpiration]" id="card_expiry" class="input-small" value="1222">
<input type="text" name="setValues[ipAddress]" id="ip" value="24.37.246.194">
...
After the form is submitted we will have the following multi-dimensional array within $_POST
:
Understand with var_dump()
the keys of the internal array:
echo '<pre>';
var_dump($_POST);
echo '</pre>';
When we try to recover the values this is what happens:
$email = (isset($_POST["setValues"])?$_POST["setValues"]["email"]:FALSE);//NULL
$email = (isset($_POST["setValues"])?$_POST["setValues"]["'email'"]:FALSE);//Retorna o e-mail preenchido no formulário
The centerpoint here is these simple quotes ' key ' that is being created inside the array key.
That’s why $_POST["setValues"]["'email'"]
works and $_POST["setValues"]["email"]
does not work, returns NULL.
So my question is how could we create this array within the input attribute without these simple quotes appearing in the key?