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.
Asked
Active
Viewed 1.6k times
8

Shahnewaz
- 360
- 4
- 12
-
3http://php.net/results.php?q=first%2520letter%2520of%2520word%2520capital&l=en&p=wholesite – deceze Apr 04 '11 at 08:57
-
First search result on Google: https://encrypted.google.com/search?q=How+to+make+first+letter+of+a+word+capital+php – Gordon Apr 04 '11 at 09:05
-
1Thanks I will keep the track of this site! – Apr 04 '11 at 09:05
-
You should try some searching on the web, because if you would searched for it on the Google you would have been got a correct answer in first place. Just keep this in mind first search and if not get the correct answer then ask. – Jack Billy Apr 04 '11 at 09:06
-
1Thanks Jack Billy, I think from next time I will do that. – Apr 04 '11 at 09:07
5 Answers
17
You may want to use ucfirst().
For multibyte strings, please see this snippet.
-
1Thanks fabrik! This worked in first place and I think I will not be a beginner for any longer! Thanks again! – Apr 04 '11 at 09:00
2
Hello Geeta you can simply use ucwords()
php function to make every first letter of your word Upper Cased!
Hope this would help!

Jack Billy
- 7,141
- 6
- 27
- 38
-
Well, actually this answer it's not so good. Why use `ucwords()` when you only need `ucfirst()`. Fabrik's answer is right on. – Bogdan Constantinescu Apr 05 '11 at 06:14
-
2
I think that http://se2.php.net/manual/en/function.ucwords.php is the best function here :)

Etu
- 41
- 3
2
This is the code you need:
<?php
$string = 'stackoverflow';
$string = ucfirst($string);
echo $string;
?>

Erre Efe
- 15,387
- 10
- 45
- 77

talk lampdeveloper
- 51
- 2