How to convert uppercase string to lowercase using PHP ? (original) (raw)

Last Updated : 18 Jul, 2024

Converting an uppercase string to lowercase means changing all capital letters in the string to their corresponding small letters. This is typically done using programming functions or methods to ensure uniformity in text formatting and comparison.

Below we have some common approaches

Table of Content

Method 1: Using strtolower()

The strtolower() function converts all alphabetic characters in a string to lowercase. This function is simple and effective for single-byte character encodings.

**Syntax:

string strtolower( $string )

**Return value: It returns the string converted into lower string.

**Example 1:

PHP `

`

Method 2: Using mb_strtolower() Function

Another efficient way to convert an uppercase string to lowercase in PHP is by using the mb_strtolower() function. This function is particularly useful for strings with multibyte characters (such as those in UTF-8) and ensures proper conversion in various languages.

Syntax:

string mb_strtolower( string,string, string,encoding = mb_internal_encoding() )

**Example:

PHP `

lowercaseString=mbstrtolower(lowercaseString = mb_strtolower(lowercaseString=mbstrtolower(uppercaseString, 'UTF-8'); echo $lowercaseString; ?>

`

array_map with strtolower

using array_map with strtolower on an array of characters. This method provides a clear and concise way to convert each character to lowercase.

**Example:

PHP `

array=strsplit(array = str_split(array=strsplit(str); lowerArray=arraymap(′strtolower′,lowerArray = array_map('strtolower', lowerArray=arraymap(strtolower,array); finalstr=implode(′′,final_str = implode('', finalstr=implode(′′,lowerArray); echo $final_str; ?>

`