PHP | array_change_key_case() Function Last Updated : 08 Jan, 2018 Comments Improve Suggest changes Like Article Like Report The array_change_key_case() function is an inbuilt function in PHP and is used to change case of all of the keys in a given array either to lower case or upper case. Syntax: array array_change_key_case(in_array, convert_case) Parameters: This function accepts two parameters out of which one is mandatory and the other is optional. The two parameters are described below: in_array (mandatory): This parameter refers to the array whose key's case is needed to be changed. convert_case (optional): This is an optional parameter and refers to the 'case' in which we need to convert the keys of the array. This can take two values, either CASE_UPPER or CASE_LOWER. CASE_UPPER value determines the uppercase and CASE_LOWER determines lowercase. If the convert_case parameter is not passed then it's default value is taken which is CASE_LOWER. Note: If the second parameter is ignored then by default the keys of array will get converted to lowercase. Return Type: The function returns an array with the changed case of the key, either to lowercase or to upper case. Let us now look at some programs to get a better understanding of working of array_change_key_case() function. Below program converts the case of keys to uppercase: PHP <?php // PHP code to illustrate array_change_key_case() // Both the parameters are passed function change_case($in_array){ return(array_change_key_case($in_array, CASE_UPPER)); } // Driver Code $array = array("Aakash" => 90, "RagHav" => 80, "SiTa" => 95, "rohan" => 85, "RISHAV" => 70); print_r(change_case($array)); ?> Output: Array ( [AAKASH] => 90 [RAGHAV] => 80 [SITA] => 95 [ROHAN] => 85 [RISHAV] => 70 ) If we ignore the second parameter convert_case in the function array_change_key_case() then the keys will be converted to lowercase. Below program illustrates this: PHP <?php // PHP code to illustrate array_change_key_case() // Second parameter is ignored function change_case($in_array){ return(array_change_key_case($in_array)); } // Driver Code $array = array("Aakash" => 90, "RagHav" => 80, "SiTa" => 95, "rohan" => 85, "RISHAV" => 70); print_r(change_case($array)); ?> Output: Array ( [aakash] => 90 [raghav] => 80 [sita] => 95 [rohan] => 85 [rishav] => 70 ) If we don't pass an array to the function then PHP_Warning is popped up, but the program works and No Output is generated. Below program illustrates this PHP <?php // PHP code to illustrate array_change_key_case() // NO parameter is passed function change_case($in_array){ return(array_change_key_case()); } // Driver Code $array = array("Aakash" => 90, "RagHav" => 80, "SiTa" => 95, "rohan" => 85, "RISHAV" => 70); print_r(change_case($array)); ?> Output: No Output Warning: PHP Warning: array_change_key_case() expects at least 1 parameter, 0 given in /home/7d540b2d77cbbfa46af4fb8798fb5e79.php on line 5 Comment More infoAdvertise with us Next Article PHP | array_change_key_case() Function chinmoy lenka Follow Improve Article Tags : PHP Functions PHP-array Practice Tags : Functions Similar Reads PHP array_keys() Function The array_keys() is a built-in function in PHP and is used to return either all the keys of and array or the subset of the keys. Syntax: array array_keys($input_array, $search_value, $strict) Parameters: The function takes three parameters out of which one is mandatory and other two are optional. $i 2 min read PHP array_âkey_âfirst() Function The array_âkey_âfirst() function is an inbuilt function in PHP that is used to get the first key of an array. This function returns the first key without affecting the internal array pointer. Syntax: int|string|null array_key_first(array $array) Parameters: This function accepts a single parameter $ 1 min read PHP array_key_exists() Function The array_key_exists() function in PHP is a built-in function that checks whether a specified key exists in an array. This function is commonly used when working with associative arrays, where keys are explicitly defined, and we need to confirm the presence of a particular key to prevent errors or u 2 min read PHP | ArrayIterator key() Function The ArrayIterator::key() function is an inbuilt function in PHP which returns the current key of the array element. Syntax: mixed ArrayIterator::key( void ) Parameters: This function does not accept any parameters. Return Value: This function returns the current array key. Below programs illustrate 1 min read PHP array_diff_key() Function This inbuilt function of PHP is used to get the difference between one or more arrays. This function compares the keys between one or more arrays and returns the difference between them. So, the function generally compares two arrays according to their keys and returns the elements that are present 2 min read PHP array_fill_keys() Function The array_fill_keys() function is a builtin function in PHP and is used to create a new array filled with the given keys and value provided as an array to the function. Syntax: array array_fill_keys ( $keys, $value ) Parameters: This function accepts two parameters, keys and their values to be prese 3 min read PHP array_combine() Function The array_combine() function is an inbuilt function in PHP which is used to combine two arrays and create a new array by using one array for keys and another array for values. That is all elements of one array will be the keys of new array and all elements of the second array will be the values of t 2 min read PHP | CachingIterator key() Function The CachingIterator::key() function is an inbuilt function in PHP which is used to return the key for the current element. Syntax: scalar CachingIterator::key( void ) Parameters: This function does not accept any parameters. Return Value: This function returns the key value of the current element. B 1 min read ArrayObject exchangeArray() function in PHP The exchangeArray() function of the ArrayObject class in PHP is used to exchange an array from an ArrayObject. That is, it replaces existing array from an ArrayObject with a newly described array. Syntax: ArrayObject exchangeArray( $inputArray ) Parameters: This function accepts a single parameter $ 2 min read PHP array_âkey_âlast() Function The array_âkey_âlast() function is an inbuilt function in PHP that is used to get the last key of an array. This function returns the last key without affecting the internal array pointer. Syntax: int|string|null array_âkey_âlast(array $array) Parameters: This function accepts single parameter $arra 1 min read Like