PHP Classes

PHP Associative Array Key Case Insensitive: Store associative array with case insensitive keys

Recommend this page to a friend!
  Info   View files Example   View files View files (1)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog    
Last Updated Ratings Unique User Downloads Download Rankings
2022-10-21 (11 months ago) RSS 2.0 feedStarStarStarStar 73%Total: 128 All time: 9,329 This week: 135Up
Version License PHP version Categories
associative-array 1.0.2GNU General Publi...5.5PHP 5, Data types
Description 

Author

This class can store associative array with case insensitive keys.

It implements the array access interface so it can store array entries using keys that are equivalent regardless of the case.

The class stores and retrieve values for array entries regardless of the case of the entries.

Picture of Christian Vigh
  Performance   Level  
Name: Christian Vigh <contact>
Classes: 32 packages by
Country: France France
Age: 57
All time rank: 13810 in France France
Week rank: 10 Up1 in France France Up
Innovation award
Innovation award
Nominee: 20x

Winner: 3x

Example

<?php
   
/***********************************************************************************************************

        The following example demonstrates the use of the AssociativeArray class.
        This example will throw an exception when trying to access undefined index 'ZZ'.

     ***********************************************************************************************************/
   
require ( 'AssociativeArray.phpclass' ) ;

    if (
php_sapi_name ( ) != 'cli' )
        echo (
"<pre>" ) ;

   
$array = new AssociativeArray ( [ 'A' => 'Value of A', 'B' => 'Value of B', 'D' => 'Value of D', 'C' => 'Value of C' ] ) ;

    echo
"Getting value of array['A'] : " . $array [ 'A' ] . "\n" ;
    echo
"Getting value of array['b'] : " . $array [ 'b' ] . "\n" ;

    echo
"********** Unsorted array contents :\n" ;
   
print_r ( $array -> ToArray ( ) ) ;

    echo
"********** Sorted array contents :\n" ;
   
$array -> ksort ( ) ;
   
print_r ( $array -> ToArray ( ) ) ;


    if ( isset (
$array [ 'ZZ' ] ) )
        echo
"Index 'ZZ' exists\n" ;
    else
        echo
"Index 'ZZ' DOES NOT exist\n" ;

   
// The following line of code will throw an exception, because index 'ZZ' is not defined
    //echo "Getting value of (inexisting) array['ZZ'] : " . $array [ 'ZZ' ] . "\n" ;




  Files folder image Files  
File Role Description
Accessible without login Plain text file example.php Example Example script

 Version Control Reuses Unique User Downloads Download Rankings  
 100%2
Total:128
This week:0
All time:9,329
This week:135Up
 User Ratings  
 
 All time
Utility:91%StarStarStarStarStar
Consistency:91%StarStarStarStarStar
Documentation:100%StarStarStarStarStarStar
Examples:83%StarStarStarStarStar
Tests:-
Videos:-
Overall:73%StarStarStarStar
Rank:213