开发者

PHP string key in array gives Undefined index

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] 开发者_JAVA技巧=> 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?


You're using the key A3L791b10M-S but it's actually A3L791B10M-S. Note the uppercase B there.


A3L791B10M-S is different from A3L791b10M-S. Watch the case...


Change the b to upper case.

A3L791B10M-S

You also may be interested in the strtoupper function.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜