数组中的 PHP 字符串键给出了未定义的索引
我有以下数组:
Array
(
[A3L791B03M-YLWS] => 1
[A3L791B03MBLKS5] => 1
[A3L791B05M-BLKS] => 2
[A3L791B05M-BLU] => 1
[A3L791B05M-BLUS] => 1
[A3L791B05M-GRY] => 2
[A3L791B05M-H-S] => 1
[A3L791B05M-REDS] => 1
[A3L791B05M-S] => 2
[A3L791B05M-WHTS] => 2
[A3L791B05M-YLWS] => 2
[A3L791B10M-BLKS] => 2
[A3L791B10M-BLUS] => 2
[A3L791B10M-GRNS] => 1
[A3L791B10M-GRY] => 2
[A3L791B10M-REDS] => 1
[A3L791B10M-S] => 3
[A3L791B10M-S?KIT] => 1
[A3L791B10M-WHTS] => 2
[A3L791B10M-YLWS] => 1
)
但是,当我尝试通过以下方式调用 A3L791b10M-S 的数据时:
echo $array_mysku_count['A3L791b10M-S'];
但是,当我这样做时,我收到以下错误:
致命错误:未捕获的异常“异常”,并带有消息“注意:未定义的索引” :A3L791b10M-S in...
所有其他键似乎都很好。导致这个问题的关键是什么?
I have the following array:
Array
(
[A3L791B03M-YLWS] => 1
[A3L791B03MBLKS5] => 1
[A3L791B05M-BLKS] => 2
[A3L791B05M-BLU] => 1
[A3L791B05M-BLUS] => 1
[A3L791B05M-GRY] => 2
[A3L791B05M-H-S] => 1
[A3L791B05M-REDS] => 1
[A3L791B05M-S] => 2
[A3L791B05M-WHTS] => 2
[A3L791B05M-YLWS] => 2
[A3L791B10M-BLKS] => 2
[A3L791B10M-BLUS] => 2
[A3L791B10M-GRNS] => 1
[A3L791B10M-GRY] => 2
[A3L791B10M-REDS] => 1
[A3L791B10M-S] => 3
[A3L791B10M-S?KIT] => 1
[A3L791B10M-WHTS] => 2
[A3L791B10M-YLWS] => 1
)
However, when I try to call for the data of A3L791b10M-S via:
echo $array_mysku_count['A3L791b10M-S'];
However, when I do so, I get the following error:
Fatal error: Uncaught exception 'Exception' with message 'Notice: Undefined index: A3L791b10M-S in...
All the other keys seems to be fine. Anything that is specific about this key that is causing this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您使用的是
A3L791b10M-S
密钥,但它实际上是A3L791B10M-S
。请注意此处的大写B
。You're using the key
A3L791b10M-S
but it's actuallyA3L791B10M-S
. Note the uppercaseB
there.A3L791B10M-S
与A3L791b10M-S
不同。关注案例...A3L791B10M-S
is different fromA3L791b10M-S
. Watch the case...将 b 更改为大写。
您可能还对
strtoupper
函数感兴趣。Change the b to upper case.
You also may be interested in the
strtoupper
function.