Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/arrays/14.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 如何获取数组[$i]调用名及其内容_Php_Arrays - Fatal编程技术网

Php 如何获取数组[$i]调用名及其内容

Php 如何获取数组[$i]调用名及其内容,php,arrays,Php,Arrays,我需要找出第一个[]中的内容以将其放入mysql,因为它等于主键 然后我也能得到里面的东西 我在考虑数组[$I] 有什么想法吗 Array ( [] => 16 [5273] => 54 [5298] => 81 [5357] => 42 [5317] => 116 [5331] => 8 [5402] => 72 [5289] => 45 [5332] => 2 )

我需要找出第一个[]中的内容以将其放入mysql,因为它等于主键

然后我也能得到里面的东西

我在考虑数组[$I]

有什么想法吗

Array
(
    [] => 16
    [5273] => 54
    [5298] => 81
    [5357] => 42
    [5317] => 116
    [5331] => 8
    [5402] => 72
    [5289] => 45
    [5332] => 2
)
试试这个:

//$array contains your array
reset($array);
echo current($array);
这将返回数组的第一个元素

或者,可以使用$array[0]引用数组的第一个元素

foreach ($array as $key => $value) {
    echo "$key=$value, "; // this will output 5273=54, 5298=81, ...
}
这就是你需要的吗