array_change_key_case – Convert Array Keys to Uppercase or Lowercase in PHP
array_change_key_case() is a PHP function that transforms all string keys in an input array to either lower‑case or upper‑case based on the specified case constant, leaving numeric indexes unchanged, and returns the modified array or FALSE if the input is not an array.
array_change_key_case() returns an array with all string keys converted to either lower‑case or upper‑case.
Explanation: The function changes the case of keys in the $input array according to the $case parameter (either CASE_LOWER or CASE_UPPER). Numeric indexes are not affected.
Parameters
input – The array to be processed.
case – Optional. One of the constants CASE_UPPER or CASE_LOWER. Default is CASE_LOWER.
Return value
Returns the array with keys converted to the chosen case; if $input is not an array, the function returns FALSE.
Example
<?php
$input_array = array(
"FirSt" => 1,
"SecOnd" => 4
);
print_r(array_change_key_case($input_array, CASE_UPPER));
?>Output:
Array
(
[FIRST] => 1
[SECOND] => 4
)Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Laravel Tech Community
Specializing in Laravel development, we continuously publish fresh content and grow alongside the elegant, stable Laravel framework.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
