PHP arrays are implemented with hash tables. The way a hash table works, to first order: it hashes the input and uses that as an index to find the right memory location to insert an object.
Now imagine your arrays are case-insensitive. Rather than doing a single hash lookup, you now have to do 2^(length of your string) hash lookups. Furthermore, of these locations, which one do you choose? Suddenly your elegant, simple hash table has become much more complicated, both computationally and in its implementation.
Furthermore, in most other languages, Key
and key
are treated differently. PHP certainly doesn't always adhere to the principle of least surprise, but in this case it does -- and that's how it should be.
As other users have pointed out, this behavior is easy to obtain if you desire it: simply convert your keys to lowercase before inserting and/or referencing them.