Reputation: 69
I have the following array below, when I do a var_dump
on $option_name
:
array (size=2)
'"name"' => string 'Large' (length=5)
'"price"' => string '12.95' (length=5)
I then try to access the name $option_name["name"]
. But every time I try to go get the value of the "name" array, I get the following error message:
Undefined index: name
So then I tried to access it like this $option_name[0]["name"]
. Still same error message. It's telling me the index "0" is undefined.
Can anyone please help me to try to figure this out? Your help will be very much appreciated!
Upvotes: 0
Views: 34
Reputation: 437336
The answer is perhaps so obvious that you don't notice it.
The keys in the array include double quotes. That is, the key is not name
but "name"
, and you would get the value you expect with $option['"name"']
or $option["\"name\""]
.
That doesn't look like something that happened on purpose, so you should probably go back to the code, find out why it happens and fix it.
Upvotes: 1