January 9, 2020
How to change array keys from uppercase to lowercase in php
In this tutorial we are going to see, how to change array keys from uppercase to lowercase.
array_change_key_case() predefined php function will be used to changes all keys in array to lowercase or uppercase.
Method Syntax : array_change_key_case(array,case);
First Parameter : array
Second parameter : It is optional,you can pass either CASE_LOWER
or CASE_UPPER
and default value is “CASE_LOWER”.
Example : array_change_key_case() function in PHP.
1 2 3 |
$input_array = array("oNe" => 10, "TwO" => 20); print_r(array_change_key_case($input_array, CASE_UPPER)); |
Output will be
1 2 3 4 5 |
Array ( [ONE] => 10 [TWO] => 20 ) |
I hope you like this Post, Please feel free to comment below.Happy Coding…