I am so confused right now, I am using code igniter php framework and have passed an array to the view so I can access the variable from within the view.
So in this view when I do
echo var_dump($data["mykey"]);
I get
string '43' (length=2)
but when I try
echo $data["mykey"];
I get
A PHP Error was encountered
Severity: Notice
Message: Undefined index: "mykey"
Line Number: 8
???
EDIT (problem seems to be when code igniter tries to return from the view to pass it back to the controller as a string, this is my conclusion because if I put a die at the end of the view it works)
The $data array is like so and in my view I try to do echo $data["myfield"][0]["data"]
array
'myfield' =>
array
0 =>
array
'data' => string '1'
'myfieldb' =>
array
0 =>
array
'data' => string '2'
When I recreate what you’ve given in PHP
It echo’s fine.
That error you’re getting means that the key specified doesn’t exist. I would do a
print_r($data)and see what you get.