PHP referencing nested array values -
i'm having trouble returning value out of nested array...
the array dump looks this
object(myobj)#1 (3) { ["thing1"]=> string(5) "abcde" ["thing2"]=> string(2) "ab" ["data"]=> array(3) { [0]=> string(3) "370" ["id"]=> string(3) "370" [1]=> string(26) "" ["name"]=> string(26) "abcdefghijklmnopqrstuvwxyz" [2]=> string(0) "" ["address"]=> string(0) "" [3]=> string(4) "wxyz" ["email"]=> string(4) "wxyz" }
i want "name" inside "data" array....
i've tried
echo $myobj['data']['name'];
also
echo $myobj -> $data -> $name;
they come undefined.
use
$myobj -> data['name'];
it sure confusing. let me explain.
the var_dump
result saw has 2 parts on them, 1 object dump , array .
object(myobj)#1 (3) { <-- starting point of object ["thing1"]=> string(5) "abcde" <-- property has string value ["thing2"]=> string(2) "ab" <-- property has string value "data" here property of object have use $myobj -> data access ["data"]=> array(3) { <-- array have use data[] access value [0]=> string(3) "370" ["id"]=> string(3) "370" [1]=> string(26) "" ["name"]=> string(26) "abcdefghijklmnopqrstuvwxyz" [2]=> string(0) "" ["address"]=> string(0) "" [3]=> string(4) "wxyz" ["email"]=> string(4) "wxyz" }
Comments
Post a Comment