Categories
PHP Tips & Tutorials

PHP: Change Array Key Case – All Array Keys to Lowercase or Uppercase

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.

By Yang Yang

Hello, I'm Yang. I build online businesses that please people. Want to join in and post some useful articles on Kavoir.com? Shoot me a message.

One reply 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.