How to make first letter of a word capital?
15,134
Solution 1
You may want to use ucfirst().
For multibyte strings, please see this snippet.
Solution 2
ucfirst capitalizes the first letter in a string.
ucwords capitalizes every word in a string.
Solution 3
Hello Geeta you can simply use ucwords()
php function to make every first letter of your word Upper Cased!
Hope this would help!
Solution 4
I think that http://se2.php.net/manual/en/function.ucwords.php is the best function here :)
Solution 5
This is the code you need:
<?php
$string = 'stackoverflow';
$string = ucfirst($string);
echo $string;
?>
Author by
Admin
Updated on June 23, 2022Comments
-
Admin almost 2 years
I have a word
default
and I want a php function to make only first letter capital. Can we do that. Please help me out as I am very new to php coding. -
Admin about 13 yearsThanks fabrik! This worked in first place and I think I will not be a beginner for any longer! Thanks again!
-
Admin about 13 yearsTHanks Philip, this helped me a lot!
-
Bogdan Constantinescu about 13 yearsWell, actually this answer it's not so good. Why use
ucwords()
when you only needucfirst()
. Fabrik's answer is right on. -
Admin about 13 yearsOk. As you say Bogdan Constantinescu.