I am having an strange issue while transversing array, created by html input. Here is my html:
<input type="hidden" name="new_date['rule'][]" value="hfgfgfgfg">
<input type="date" name="new_date['date'][]" />
if I submit form then I get array like this:
$var=$_POST['new_date'];
echo"<pre>";
print_r($var);
echo"</pre>";
//output
Array
(
['rule'] => Array
(
[0] => rule_5a6c50ff02fff
)
['date'] => Array
(
[0] => 2018-05-24
)
)
if I am trying the array with key rule then I am getting nothing or empty.
print_r($var['rule']);
//output
.....empty......
Please help. TIA
In HTML you have used new_date['rule'][] which have key as 'rule' so while retriving through POST you need to use same key i.e. with single quote
USE below:
var_dump($var["'rule'"])
To use : $var['rule'] you may need to use new_date[rule][] in your html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With