user5329895
user5329895

Reputation:

Get value from an array in php?

When I check value of an array using var_dump() function.

var_dump($data['content']);

I have result

array(1) { [0]=> array(10) { ["IDUser"]=> string(1) "1" ["Name"]=> string(5) "admin" ["Password"]=> string(32) "44ca5fa5c67e434b9e779c5febc46f06" ["Fullname"]=> string(18) "Nguyễn Tá Lợi" ["Gender"]=> string(1) "0" ["Birthday"]=> string(10) "0000-00-00" ["Address"]=> string(0) "" ["Email"]=> string(0) "" ["PhoneNumber"]=> string(0) "" ["Status"]=> string(1) "1" } }

I want get value with key ["Name"] so I use $data['content']['Name'] but it's incorrect
How to get value of "Name" in this array?

Upvotes: 2

Views: 60

Answers (2)

devpro
devpro

Reputation: 16117

Value of Name is available on 0 index of content so you can not get the Name value as:

$data['content']['Name']

You need to get Name as:

$data['content'][0]['Name'] // add 0 index of content.

Upvotes: 2

user3253002
user3253002

Reputation: 1671

$data['content'][0]['Name'] should do it

Upvotes: 3

Related Questions