How to convert array values to lowercase in PHP?

Today now in this post i would like to share with you How to convert array values to lowercase in PHP. Whenever we need to create all the array value in lowercase then we can create that without using any loop. we need to just use array_map(), array_map function take two arguments one of them for php function “strtolower” and the second one for array. So it may be we need to do this when we are working on any big projects and we need to all values in the small case.

So, here you will know how to convert array values to lowercase by using array_map().

Let’s see the bellow example and learn how it’s work.


$myArray = ['1'=>'Hey','2'=>'Hello','3'=>'Hi','4'=>'GM'];
$result = array_map('strtolower',$myArray);

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.


About Shahriar Sagor

My name is Shahriar sagor. I'm a developer. I live in Bangladesh and I love to write tutorials and tips that will help to other Developer's. I am a big fan of PHP, Javascript, JQuery, Laravel, Codeigniter, VueJS, AngularJS and Bootstrap from the early stage.

View all posts by Shahriar Sagor →