PHP | array_change_key_case() Function Last Updated : 08 Jan, 2018 Summarize Comments Improve Suggest changes Share 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 C chinmoy lenka Follow Improve Article Tags : PHP Functions PHP-array Practice Tags : Functions Similar Reads Architecture of 8085 microprocessor A microprocessor is fabricated on a single integrated circuit (IC) or chip that is used as a central processing unit (CPU).The 8085 microprocessor is an 8-bit microprocessor that was developed by Intel in the mid-1970s. It was widely used in the early days of personal computing and was a popular cho 11 min read States of a Process in Operating Systems In an operating system, a process is a program that is being executed. During its execution, a process goes through different states. Understanding these states helps us see how the operating system manages processes, ensuring that the computer runs efficiently. Please refer Process in Operating Sys 11 min read PHP Tutorial PHP is a widely used, open-source server-side scripting language primarily designed for web development. It is embedded directly into HTML and generates dynamic content on web pages. It allows developers to handle database interactions, session management, and form handling tasks.PHP code is execute 9 min read Function Overloading in C++ C++ function overloading allows you to define multiple functions with the same name but different parameters. It is a form of compile time polymorphism in which a function can perform different jobs based on the different parameters passed to it. It is a feature of object-oriented programming that i 6 min read Top 60+ PHP Interview Questions and Answers -2025 PHP is a popular server-side scripting language, widely known for its efficiency in web development and versatility across various platforms. PHP is extensively utilized by top companies such as Facebook, WordPress, Slack, Wikipedia, MailChimp, and many more due to its robust features and high perfo 15+ min read PHP Introduction PHP stands for Hypertext Preprocessor. It is an open-source, widely used language for web development. Developers can create dynamic and interactive websites by embedding PHP code into HTML. PHP can handle data processing, session management, form handling, and database integration. The latest versi 8 min read PHP Arrays Arrays are one of the most important data structures in PHP. They allow you to store multiple values in a single variable. PHP arrays can hold values of different types, such as strings, numbers, or even other arrays. Understanding how to use arrays in PHP is important for working with data efficien 5 min read PHP | Functions A function in PHP is a self-contained block of code that performs a specific task. It can accept inputs (parameters), execute a set of statements, and optionally return a value. PHP functions allow code reusability by encapsulating a block of code to perform specific tasks.Functions can accept param 8 min read Difference between HTTP GET and POST Methods HTTP (Hypertext Transfer Protocol) specifies a collection of request methods to specify what action is to be performed on a particular resource. The most commonly used HTTP request methods are GET, POST, PUT, PATCH, and DELETE. This article covers the 2 most common HTTP request methods, i.e. the GET 4 min read PHP Data Types In PHP, data types define the kind of value a variable can hold. PHP is a loosely typed language, meaning you donât need to declare the data type of a variable. It is automatically assigned based on the value. But it is important to understand data types because it is important for writing reliable, 4 min read Like