相关疑难解决方法(0)

PHP - 获取数组值的键名

我有一个数组如下:

function example() {
    /* some stuff here that pushes items with
        dynamically created key strings into an array */

    return array( // now lets pretend it returns the created array
        'firstStringName' => $whatEver,
        'secondStringName' => $somethingElse
    );
}

$arr = example();

// now I know that $arr contains $arr['firstStringName'];
Run Code Online (Sandbox Code Playgroud)

我需要找出索引,$arr['firstStringName']以便我能够循环array_keys($arr)'firstStringName'通过其索引返回键字符串.我怎样才能做到这一点?

php arrays array-key

139
推荐指数
9
解决办法
33万
查看次数

标签 统计

array-key ×1

arrays ×1

php ×1