Array keys and case sensitivity
Yep, array keys are case sensitive.
So you can do:
< ?php
$a = array('key'=> 1, 'Key' => 2);
print_r($a);
?>and it will print
Array ( [key] => 1 [Key] => 2 )
Similarly if you call array_keys() on $a, like:
< ?php
$a = array('key'=> 1, 'Key' => 2);
print_r(array_keys($a));
?>...you'll get:
Array ( [0] => key [1] => Key )
Defining the same key in an array (even in the same array declaration) won't cause an error, but will result in the latest value taking precedence. Like:
< ?php
$a = array('key'=> 1, 'key' => 2);
print_r($a);
?>will output:
Array ( [key] => 2 )
This entry was posted on Tuesday, March 29th, 2005 and is filed under PHP certification. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.
Get notification for future posts: follow me on Twitter or subscribe to my RSS feed
