How to use str_replace( ) function In PHP

PHP str_replace() method replaces each uppercase character in the string with its corresponding lowercase character using str_replace( ).

$string = "w3wiki";
$lowercaseString = str_replace(range('A', 'Z'), range('a', 'z'), $string);
echo "Lowercase using str_replace(): $lowercaseString";

How to convert a String to Lowercase in PHP?

Converting a string to lowercase in PHP is a common operation that allows you to standardize string formats or perform case-insensitive comparisons.

Table of Content

  • Using strtolower() function
  • Using mb_strtolower() function
  • Using str_replace( ) function
  • Using Loop

Similar Reads

Using strtolower() function:

PHP strtolower() converts all alphabetic characters in a string to lowercase....

Using mb_strtolower() function

PHP mb_strtolower() performs case folding on a string, allowing accurate lowercase conversion for multibyte encodings like UTF-8....

Using str_replace( ) function

PHP str_replace() method replaces each uppercase character in the string with its corresponding lowercase character using str_replace( )....

Using Loop

This approach involves iterating through each character in the string and converting it to lowercase using strtolower()....