Reputation: 2647
I've been struggling with this stuff for two days, I need help, lol. I'm trying to handle a post that has some inputs as an array.
To understand the structure of the array, here's a print_r($_POST)
print_r($_POST):
Array
(
[prov] => 49
[almacen] => 1
[fecha] => 24-01-2014
[a] => Array
(
['1545'] => Array
(
[0] => 1
)
['908'] => Array
(
[0] => 1
)
)
[p] => Array
(
['1545'] => Array
(
[0] => 0.6
)
['908'] => Array
(
[0] => 0
)
)
[d] => Array
(
['1545'] => Array
(
[0] => 20
)
['908'] => Array
(
[0] => 0
)
)
[e] => Array
(
['1545'] => Array
(
[0] => 2
)
['908'] => Array
(
[0] => 0
)
)
)
If I do a print_r($_POST["p"]) this is what I get (as expected):
Array
(
['1545'] => Array
(
[0] => 0.6
)
['908'] => Array
(
[0] => 0
)
)
but, if I try to go further with print_r($_POST["p"][0]), I receive a:
Notice: Undefined offset: 0
or print_r($_POST["p"]["1545"]) also fails with undefined offset.
How can I get $_POST["p"]["1545"] not returning undefined.
Thanks!
Upvotes: 0
Views: 1096
Reputation: 24384
Try to get 1545
with '
print_r($_POST["p"]["'1545'"]);
it seems like '1545'
is the actual key for array $_POST['p']
it means that you have error in your HTML
Upvotes: 2