I am trying to call an associative array and I am confused why this would not work.
if I print_r($test); it shows the following:
Array(
[e7a36fadf2410205f0768da1b61156d9] => Array(
[rowid] => e7a36fadf2410205f0768da1b61156d9
[id] => 3
[qty] => 1
[price] => 20
[name] => test
[options] => Array(
[permName] => large
)
[subtotal] => 20
)
)
but if I do $test[0]["rowid"]; it gives the following error Message: Undefined offset: 0
I am still a php newbie but from what I have learned about arrays so far this should work. Any ideas?
Thanks
Your array is associative so
$test[0]doesn’t exist.If you want to get the first element without referencing the key you can use
reset($test)The two examples are functionality identical.