While you can easily fabricate your own functions to do this element by element, you can simply resort to the php function array_change_key_case() to do it for you:
$new_array = array_change_key_case($old_array, CASE_UPPER);
Changes all the keys in $old_array to upper case and
$new_array = array_change_key_case($old_array, CASE_LOWER);
Changes all the keys in $old_array to lower case.
1 thought on “PHP: Change Array Key Case – All Array Keys to Lowercase or Uppercase”
I have tried this code its good but if i need to change the array value in lower or upper case then what can i do….?
Comments are closed.