Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/245.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/arrays/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 获取密钥&;使用数字索引的关联数组中的值_Php_Arrays_Associative Array - Fatal编程技术网

Php 获取密钥&;使用数字索引的关联数组中的值

Php 获取密钥&;使用数字索引的关联数组中的值,php,arrays,associative-array,Php,Arrays,Associative Array,我有一个数组: $array = array( '001' => '555', '002' => '666', '003' => '777' ); 我希望使用数字索引获得键和值 $key = $array[0]; $value = $array[0][]; 我正在使用数字索引,因为执行时数组的大小未知使用数组\u键获取键: $keys = array_keys($array); $key = $keys[0]; $value = $array[

我有一个数组:

$array = array(
     '001' => '555',
     '002' => '666',
     '003' => '777'
);
我希望使用数字索引获得键和值

$key = $array[0];
$value = $array[0][];

我正在使用数字索引,因为执行时数组的大小未知

使用
数组\u键
获取键:

$keys = array_keys($array);
$key = $keys[0];
$value = $array[$key];