Skip to content

Associative arrays with case insensitive keys for PHP

Notifications You must be signed in to change notification settings

leijou/CaseInsensitiveArray

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 

Repository files navigation

CaseInsensitiveArray

Associative arrays with case insensitive keys for PHP

This is a convenient single-class version compiled from the more abstract CustomHashArray

Usage

$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

Behaviour

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.

About

Associative arrays with case insensitive keys for PHP

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages