How to convert array key to lowercase in PHP?
In this post we will give you information about How to convert array key to lowercase in PHP?. Hear we will give you detail about How to convert array key to lowercase in PHP?And how to use it also give you demo for it if it is necessary.
Whenever you require to create all array key in lowercase then you can create that without using loop. you have to just use array_change_key_case(), array_change_key_case function take two argument one for array and second one for php function “CASE_LOWER”. May be we need to do this when we are working on big projects and need to all key in small case.
So, how to convert array values to lowercase using array_change_key_case(), see bellow example and learn how to work.
Example:
$myArray = ['Hey'=>'Hey','HELLO'=>'Hello','hi'=>'Hi','Gm'=>'GM'];
$result = array_change_key_case($myArray, CASE_LOWER);
print_r($result);
Output:
Array
Array
(
[hey] => Hey
[hello] => Hello
[hi] => Hi
[gm] => GM
)
Hope this code and post will helped you for implement How to convert array key to lowercase in PHP?. if you need any help or any feedback give it in comment section or you have good idea about this post you can give it comment section. Your comment will help us for help you more and improve us. we will give you this type of more interesting post in featured also so, For more interesting post and code Keep reading our blogs