PHP strtolower is an inbuilt function in PHP. It converts a PHP string to lowercase characters. In this article, we will discuss this function. Also, we will discuss a few examples of using it.
Also, you can convert a string to uppercase characters using PHP strtoupper Function.
The function returns a string after converting all alphabetical characters to lowercase.
Let’s consider a couple of examples of using the function.
Example 1: Simple String
You can pass an alphabetical string to the function and convert it to lowercase.
<?php $string = 'THIS IS A STRING 234'; $uppercase = strtolower($string); echo $uppercase; /* this is a string 234 */ ?>
Example 2: Array of Strings
You can use the PHP array_map Function to directly convert all the strings in an array to lowercase by passing strtolower as the callback function.
<?php $arrayOfStrings = array( 'STRING 1', 'STRING 2 is UPPER', 'ANOTHER STRING' ); $lowerCaseArray = array_map('strtolower', $arrayOfStrings); print_r($lowerCaseArray); /* Array (  => string 1  => string 2 is upper  => another string ) */ ?>
Vishesh is currently working as a Senior Software Engineer at Naukri.com. He passed out of Delhi College of Engineering in 2016 and likes to play Foosball. He loves traveling and is an exercise freak. His expertise includes Java, PHP, Python, Databases, Design and Architecture.