offset 0 php,php數組偏移0,當0存在時

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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值