How To Convert Uppercase To Lowercase In PHP?

What we are going to see through this article is How To Convert Uppercase To Lowercase In PHP?. In order to make this work, we first need to establish a string that we want to make lowercase.

Here I create a variable $myUpperCaseString and have a sentence that is in all uppercase letters.

In this article you’ll look at PHP’s string functions for converting text between uppercase and lowercase:

  • strtolower() for converting a string to lowercase
  • strtoupper() for converting a string to uppercase
  • lcfirst() for converting the first letter to lowercase
  • ucfirst() for converting the first letter to uppercase
  • ucwords() for converting each word to uppercase
How To Convert Uppercase To Lowercase In PHP

Convert Uppercase to Lowercase in PHP

<?php

// original string
$str = "Welcome to Our Website Codingdeekshi.com";

// string converted to lower case
$resStr = strtolower($str);

print_r($resStr);

?>

Output

welcome to our website codingdeekshi.com

Convert Uppercase to Lowercase in PHP

Now, We can see the 2nd example program to perform a task in the below program.

<?php

// original string
$str = "The dog barked,” Daniel, the Lord, and Queen Elizabeth";

// string converted to lower case
$resStr = strtolower($str);

print_r($resStr);

?>

Output

the dog barked,"daniel, the lord, and queen elizabeth

Read Also: Convert Array To String In PHP

Final Thoughts

What we learned through this article is How To Convert Uppercase To Lowercase In PHP?. Also if you have any doubts please leave a comment via the comment box. And we ask that you benefit everyone who shared this article with your friends.

Leave a Comment