Today now in this post i would like to share with you how to convert array key to lowercase in PHP. Whenever we need to create all array key in lowercase and then we need to change to. We can create that without by using any loop. we can do this just by use array_change_key_case(), array_change_key_case functions. It takes just two argument one for array and the second one for php function “CASE_LOWER”. May be we need to do this when if we are working on any big projects and we also need to all key in small case.
So, here we will know about how to convert an array values to lowercase by using array_change_key_case(),
so let’s see bellow example and learn how to work.
$myArray = ['Hey'=>'Hey','HELLO'=>'Hello','hi'=>'Hi','Gm'=>'GM']; $result = array_change_key_case($myArray, CASE_LOWER); print_r($result);
Read Also : How to convert Object into Array in PHP?
Thanks for read. I hope it help you. For more you can follow us on facebook.