How to convert the first letter of a string to uppercase in PHP

How to convert the first letter of a string to uppercase in PHP

In this post we will give you information about How to convert the first letter of a string to uppercase in PHP. Hear we will give you detail about How to convert the first letter of a string to uppercase in PHPAnd how to use it also give you demo for it if it is necessary.

Use the PHP ucfirst() function

You can use the PHP ucfirst() function to change the first character of a string to uppercase (i.e. capital). Alternatively, you can use the strtolower() function in combination with the ucfirst() function, if you want to make only first letter of the string to uppercase and rest of the string to lowercase. Let’s check out an example to understand how it works:

<?php
$str1 = 'the color of the sky is blue.';
echo ucfirst($str1);
echo "<br>";
$str2 = 'the Color of the Sky is Blue.';
echo ucfirst(strtolower($str2));
?>

i hope you like this article.

Hope this code and post will helped you for implement How to convert the first letter of a string to uppercase in PHP. if you need any help or any feedback give it in comment section or you have good idea about this post you can give it comment section. Your comment will help us for help you more and improve us. we will give you this type of more interesting post in featured also so, For more interesting post and code Keep reading our blogs

For More Info See :: laravel And github

We're accepting well-written guest posts and this is a great opportunity to collaborate : Contact US