Associative arrays with case insensitive keys for PHP
This is a convenient single-class version compiled from the more abstract CustomHashArray
$arr = new CaseInsensitiveArray;
$arr['HelloWorld'] = 'hi';
echo $arr['helloworld'];
// Outputs: hi
$arr['other'] = 'Other thing';
$arr['helloWorld'] = 'Same key';
foreach ($arr as $key => $value) {
echo $key.' => '.$value."\n";
}
// Outputs:
// other => Other thing
// helloWorld => Same key
Key access is case insensitive. When accessing the array's keys they will be returned as the original case that defined them.
If an existing key is overwritten with a different case the new case will be used when returning key names.