PHP array, Are array indexes case sensitive?

后端 未结 6 606
抹茶落季
抹茶落季 2020-12-03 09:44

I don\'t know if this is a problem yet but wanted to start thinking about it.

Question:

\"Are PHP array indexes case sensitive\"?

Ex

相关标签:
6条回答
  • 2020-12-03 10:05

    Answer:

    Yes, they are.

    0 讨论(0)
  • 2020-12-03 10:07

    Yes. They are case sensitive.

    PHP array indexes act as hash tables in your example. A capital letter "A" and a lowercase letter "a" have different hash values, therefore they will be different indexes.

    0 讨论(0)
  • 2020-12-03 10:14

    just like everyone else mentioned, "Yes They Are".

    fore example $a['id'] is different with $a['ID']

    0 讨论(0)
  • 2020-12-03 10:18

    That's easy enough to check on your own.

    $dogs = array('Dog' => 'Wuff', 'dog' => 'wuff', 'DOG' => 'WUFF');
    var_dump($dogs);
    
    0 讨论(0)
  • 2020-12-03 10:25

    Yes, just like variable names (but not function names), hash keys are case-sensitive.

    0 讨论(0)
  • 2020-12-03 10:27

    Although it's not true of the system with which most people are familiar (Windows), it's a reasonable assumption to make when approaching any new language or environment that it will be case sensitive. PHP is along with virtually every other language and environment in common use. The most notable exceptions that spring to mind (apart from the aforementioned Windows) are SQL and Delphi (Pascal).

    0 讨论(0)
提交回复
热议问题