php Undefined index but i can access that key anyways

Posted by Linas on Stack Overflow See other posts from Stack Overflow or by Linas
Published on 2012-10-17T22:59:07Z Indexed on 2012/10/17 23:00 UTC
Read the original article Hit count: 192

Filed under:

I just don't get it, i know what the error means i know how to fix it but it seems to be more of a php bug, i have an array returned from some function which looks like this when i use var_dump:

array(1) {
  ["89512480-1884-11e2-aee6-618bca23e5b1"]=>
  array(5) {
    ["created"]=>
    string(10) "1350514509"
    ["expires"]=>
    string(10) "1351724109"
    ["token"]=>
    string(40) "81fa1895a6d5d4cb11efae8e71adf98fbdbfb5ca"
    ["user_agent"]=>
    string(40) "6ab18a2ea1d4b17d67713e416b07d46bf2f4d03b"
    ["username"]=>
    string(4) "test"
  }
}
array(0) {
}

but if i try for example:

echo $token['89512480-1884-11e2-aee6-618bca23e5b1']['user_agent'];

it shows me the value, but at the same time i get that annoying error, what the hell?

© Stack Overflow or respective owner

Related posts about php5