0

After a json_decode this is the var_dump of the assoc array:

array(1) { 
    [0]=> array(8) { 
        ["Username"]=> string(11) "test" 
        ["FirstName"]=> string(6) "Test1" 
        ["LastName"]=> string(5) "Test2" 
        ["Gender"]=> string(6) "Male" 
     }
}

if try to echo $array["FirstName"] it doesn't display anything, I've tried everything and nothing works.

2
  • 3
    try $array[0]["FirstName"] Commented Apr 25, 2013 at 23:56
  • Always format your code so that others can read and understand it. Commented Apr 26, 2013 at 0:03

1 Answer 1

2

That's because there is no such key as FirstName on the main array. However, there is one on the inner array.

echo $array[0]['FirstName'];

Note that if you had enabled show_errors and had suitable error_reporting set, you would have seen a Notice-level error informing you of the problem.

Sign up to request clarification or add additional context in comments.

1 Comment

Thank you for all your help everyone, I'll be sure to do that next time.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.