从php数组中获取值?

时间:2021-06-29 22:07:25

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

当我使用var_dump()函数检查数组的值时。

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?

我想要使用key ["Name"]获取值,所以我使用$data['content']['Name'],但是如何在这个数组中获取"Name"的值是不正确的?

2 个解决方案

#1


3  

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

$ data[0](“内容”)(“名字”)应该做它

#2


2  

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

名称的值在内容索引为0时可用,因此不能得到名称的值为:

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

You need to get Name as:

您需要获得名称为:

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

#1


3  

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

$ data[0](“内容”)(“名字”)应该做它

#2


2  

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

名称的值在内容索引为0时可用,因此不能得到名称的值为:

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

You need to get Name as:

您需要获得名称为:

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