Menu

Add Topic

programming

waiting answer July 28, 2021

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

Answers
June 10, 2021

The PHP built-in function ucfirst() is used to the first letter of a string to uppercase. You can also use the PHP function strtolower() with the combination of ucfirst() function.

Let's check the following example to understand how this function actually works

     <?php
        $string1 = 'welcome to America';
        echo ucfirst($string1);
        echo "<br>";
        $string2 = 'nice to meet you';
        echo ucfirst(strtolower($string2));
    ?>

OUTPUT

        Welcome to America
        Nice to meet you

0 0

Please Login to Post the answer

Leave an Answer