Programming Tutorials

PHP convert string to lower case

By: Manoj in PHP Tutorials on 2023-03-22  

In PHP, you can convert a string to lowercase using the strtolower() function. Here is an example:

$str = "HELLO WORLD"; 
$str_lower = strtolower($str);
echo $str_lower; // Output: hello world

In the example above, we first define a string $str in uppercase. We then use the strtolower() function to convert it to lowercase and store the result in a new variable $str_lower. Finally, we output the lowercase string using the echo statement.

Note that strtolower() function returns a new string in lowercase and doesn't modify the original string. If you want to modify the original string, you can assign the result of strtolower() back to the original variable:

$str = "HELLO WORLD"; 
$str = strtolower($str);
echo $str; // Output: hello world





Add Comment

* Required information
1000

Comments

No comments yet. Be the first!

Most Viewed Articles (in PHP )

PHP code to write to a CSV file from MySQL query

Different versions of PHP - History and evolution of PHP

PHP code to import from CSV file to MySQL

Encrypting files using GnuPG (GPG) via PHP

PHP Warning: Unknown(): Unable to load dynamic library '/usr/local/php4/lib/php/extensions/no-debug ......

A Basic Example using PHP in AWS (Amazon Web Services)

Send push notifications using Expo tokens in PHP

Decrypting files using GnuPG (GPG) via PHP

Count occurrences of a character in a String in PHP

Error: Length parameter must be greater than 0

Password must include both numeric and alphabetic characters - Magento

Reading word by word from a file in PHP

Parent: child process exited with status 3221225477 -- Restarting

Convert a hex string into a 32-bit IEEE 754 float number in PHP

Exception in module wampmanager.exe at 000F15A0 in Windows 8

Latest Articles (in PHP)