访问数组中的元素 [英] Accessing elements in array

查看:56
本文介绍了访问数组中的元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在php中有一个变量, print_r :

I have a variable in php, print_r:

Array ( 
    [0] => Array ( 
        [0] => Array ( 
            [sum(`Lgsl`.`players`)] => 7769 
        ) 
    )
)

我有一些类似的结构.从中获取 7769 号而不引用最新数组中的字符串键的最简单方法是什么.

And I have a few such arrays with similiar structure. What is the easiest way to get 7769 number from it without referencing to string-key in latest array.

推荐答案

list ($number) = array_values($arr[0][0]);

函数 array_values 返回带有数字索引的所有值的列表,以便您可以访问第一个和第二个通过索引 0 的唯一元素. list 关键字可以将数组元素提取到单独的变量中.

The function array_values returns a list of all values with a numeric index, so that you can access the first and only element via index 0. The list keyword can extract array elements into separate variables.

这篇关于访问数组中的元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆