PHP String to Uppercase to Lowercase & Lowercase to Uppercase

PHP String to Uppercase to Lowercase & Lowercase to Uppercase

Converts string to lowercase to uppercase and uppercase to lowecase; In this tutorial, we will show you, how to convert string to uppercase and how to convert string to lowercase and how to convert the uppercase first letter of each word in PHP with its definition, syntax, parameters, and examples.

PHP String to Uppercase to Lowercase & Lowercase to Uppercase

  • 1. PHP convert string to lowercase
  • 2. PHP convert string to uppercase
  • 3. PHP uppercase first letter of each word

1. PHP convert string to lowercase

You can use the php inbuilt function strtolower() for convert string to lowercase.

PHP strtolower() Function

strtolower() is a inbuilt PHP function, which is used to convert string to lowercase.

Note:- This function accept only one parameter as string.

Syntax of this function is:
 strtolower( string );
Example for convert string to lowercase

Let’s take an example, in this example, we have a one-string and we will use the strtolower() function to convert string to lowercase.

<?php 
  
// original string 
$str = "Hello Developers, Have Good Day!"; 
  
// convert string to lowercase
$res = strtolower($str); 
  
echo $res;

  
?> 

The output of the above code is:- ” hello developers, have good day! “

2. PHP convert string to uppercase

You can use the PHP inbuilt function strtoupper() for convert string to uppercase.

PHP strtoupper() Function

strtoupper() is an inbuilt PHP function, which is used to convert string to strtoupper.

Note:- This function accepts only one parameter as a string.

Syntax of this function is:
 strtoupper( string );
Example for convert string to uppercase

Let’s take an example, in this example, we have a one-string and we will use the strtoupper() function to convert string to uppercase.

<?php 
  
// original string 
$str = "hello developers, have good day!"; 
  
// convert string to uppercase
$res = strtoupper($str); 
  
echo $res;

  
?> 

The output of the above code is:- “HELLO DEVELOPERS, HAVE GOOD DAY!”

3. PHP uppercase first letter of each word

You can use the PHP inbuilt function ucwords() for convert uppercase first letter of each word.

PHP ucwords() Function

ucwords() is an inbuilt PHP function, which is used to convert the first letter of each word in a string to uppercase.

Syntax of this function is:
ucwords(string, delimiters);
Example for php uppercase first letter of each word

Let’s take an example, we have a one-string and we will use the ucwords() function to uppercase the first letter of each word.

<?php 
  
// original string 
$str = "hello developers, have good day!"; 
  
// convert string to uppercase
$res = ucwords($str); 
  
echo $res;

  
?> 

The output of the above code is: ” Hello Developers, Have Good Day! “

AuthorAdmin

Greetings, I'm Devendra Dode, a full-stack developer, entrepreneur, and the proud owner of Tutsmake.com. My passion lies in crafting informative tutorials and offering valuable tips to assist fellow developers on their coding journey. Within my content, I cover a spectrum of technologies, including PHP, Python, JavaScript, jQuery, Laravel, Livewire, CodeIgniter, Node.js, Express.js, Vue.js, Angular.js, React.js, MySQL, MongoDB, REST APIs, Windows, XAMPP, Linux, Ubuntu, Amazon AWS, Composer, SEO, WordPress, SSL, and Bootstrap. Whether you're starting out or looking for advanced examples, I provide step-by-step guides and practical demonstrations to make your learning experience seamless. Let's explore the diverse realms of coding together.

Leave a Reply

Your email address will not be published. Required fields are marked *