when i echo
當我回聲
print_r(array_values(array_filter($exampleArray[5]["Numbers"])));
I get an array which looks like
我得到一個看起來像的數組
Array ( [0] => 100
[1] => 31
[2] => 023 )
But when i echo the statement
但是,當我回應聲明時
print_r(array_values(array_filter($exampleArray[5]["Numbers"][0])));
I get
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
messages. Clearly there is a 0 index but i don't know why i'm getting errors.
消息。顯然有0指數,但我不知道為什么我會收到錯誤。
1 个解决方案
#1
2
Simple As that $exampleArray[5]["Numbers"][0] is not an array rather it is a String.
簡單因為$ exampleArray [5] [“Numbers”] [0]不是數組而是字符串。
If you want to get the index[0] value you should call index 0 on array_values response
如果要獲取index [0]值,則應在array_values響應上調用索引0
print_r(array_values(array_filter($exampleArray[5]["Numbers"]))[0]);
The above code will return 100
上面的代碼將返回100