存在0时,php数组偏移量为0
当我回音存在0时,php数组偏移量为0,php,arrays,Php,Arrays,当我回音 print_r(array_values(array_filter($exampleArray[5]["Numbers"]))); 我得到一个数组,看起来像 Array ( [0] => 100 [1] => 31 [2] => 023 ) 但当我附和这句话的时候 print_r(array_values(array_filter($exampleArray[5]["Numbers"][0]))); 我明白了 Notice:
print_r(array_values(array_filter($exampleArray[5]["Numbers"])));
我得到一个数组,看起来像
Array ( [0] => 100
[1] => 31
[2] => 023 )
但当我附和这句话的时候
print_r(array_values(array_filter($exampleArray[5]["Numbers"][0])));
我明白了
Notice: Undefined offset: 0
Warning: array_filter() expects parameter 1 to be array, null given
Warning: array_values() expects parameter 1 to be array, null given
信息。
显然有一个0索引,但我不知道为什么会出错。就这么简单,
$exampleArray[5][“Numbers”][0]
不是数组,而是字符串
如果要获取索引[0]
值,应在array\u values
响应中调用index0
print_r(array_values(array_filter($exampleArray[5]["Numbers"]))[0]);
上面的代码将返回
100
简单,因为$exampleArray[5][“Numbers”][0]
不是数组,而是字符串
如果要获取索引[0]
值,应在array\u values
响应中调用index0
print_r(array_values(array_filter($exampleArray[5]["Numbers"]))[0]);
上述代码将返回100