Wednesday, 24 September 2014

array_change_key_case in PHP

Using array_change_key_case() function you can change all array KEYS into lower case or upper case.

Syntax: array_change_key_case(array,case)

Parameters Description:
array : Required. Set the array to use.
case : Optional.
       Set the possible values:

  • CASE_LOWER - Default value. Returns the array key values in lower case.
  • CASE_UPPER - Returns the array key values in upper case.
Example:
<?php
$days = array( "a"=>"Sunday","b"=>"Monday","c"=>"Tuesday","A"=>"Wednesday");
print_r( array_change_key_case($days,CASE_UPPER) );
?>
Output:

Array (
            [A] => Wednesday
            [B] => Monday
            [C] => Tuesday 
         )

0 comments:

Post a Comment