array_change_key_case()

array_change_key_case ($input_array , int $size [, bool $preserve_keys = FALSE ] )
ParameterDESCRIPTION
$input_arrayRequired : Input array to change key cases
$caseOptional : CASE_LOWER ( default ) , keys will be changed to lower case
CASE_UPPER , keys will be changed to upper case
Return value is an array with keys changed to Upper case or Lower case.

Example 1

$input=array('One'=>1,'Two'=>2,'Three'=>3,'Four'=>4,'Five'=>5);
$output=array_change_key_case($input);
echo print_r($output);
Output is here
Array ( [one] => 1 [two] => 2 [three] => 3 [four] => 4 [five] => 5 ) 1

Example 2 with CASE_UPPER

$input=array('One'=>1,'Two'=>2,'Three'=>3,'Four'=>4,'Five'=>5);
$output=array_change_key_case($input,CASE_UPPER);
echo print_r($output);
Output is here
Array ( [ONE] => 1 [TWO] => 2 [THREE] => 3 [FOUR] => 4 [FIVE] => 5 ) 1

Example 3 with CASE_LOWER ( default )

$input=array('One'=>1,'Two'=>2,'Three'=>3,'Four'=>4,'Five'=>5);
$output=array_change_key_case($input,CASE_LOWER);
echo print_r($output);
Output is here
Array ( [one] => 1 [two] => 2 [three] => 3 [four] => 4 [five] => 5 ) 1
Getting keys of an array
Array REFERENCE
Subhendu Mohapatra — author at plus2net
Subhendu Mohapatra

Author

🎥 Join me live on YouTube

Passionate about coding and teaching, I publish practical tutorials on PHP, Python, JavaScript, SQL, and web development. My goal is to make learning simple, engaging, and project‑oriented with real examples and source code.



Subscribe to our YouTube Channel here



plus2net.com











PHP video Tutorials
We use cookies to improve your browsing experience. . Learn more
HTML MySQL PHP JavaScript ASP Photoshop Articles Contact us
©2000-2025   plus2net.com   All rights reserved worldwide Privacy Policy Disclaimer