PHP strtolower() function for lowercase string

Posted on Aug 13, 2022

How to use strtolower() to create a lowercase PHP string

Photo from Unsplash

The PHP strtolower() function is used to convert string characters to lowercase.

The function accepts a string to be converted and returns a string with all lowercase characters:

strtolower(string $string): string

This function doesn’t affect any numeric or special character in the string.

Here are some examples of using the function:

$str = "Nathan Sebhastian";

// 👇 convert to lowercase
$str = strtolower($str);

// 👇 nathan sebhastian
echo $str; 

$str = "JACK is a SOFTware DEVeloper";

// 👇 convert to lowercase
$str = strtolower($str);

// 👇 jack is a software developer
echo $str; 

The function reference is documented at: https://www.php.net/manual/en/function.strtolower.php

Level up your programming skills

I'm sending out an occasional email with the latest programming tutorials. Drop your email in the box below and I'll send new stuff straight into your inbox!

No spam. Unsubscribe anytime.