Click to See Complete Forum and Search --> : [RESOLVED] capitalize Letters?
rscape
Aug 3rd, 2007, 06:05 PM
$words="a sentence";
echo $words;
How would I make the start of every new word a capital letter?
edit: found out, cant make post resolved.
RudiVisser
Aug 4th, 2007, 08:14 AM
It does help to post the resolution so that other people with your problem/question can have the knowledge to fix it also.
$words = strtoupper("a sentence");
echo $words;
penagate
Aug 4th, 2007, 08:28 AM
Rudi, that will convert the whole string to uppercase. To capitalise the first character of every word, use ucwords().
rscape, Sorry, I forgot to mention this at the time, but I marked your thread as resolved for you. You should be able to do this in future from the Thread Tools menu. Let me know if you cannot.
RudiVisser
Aug 4th, 2007, 08:35 AM
Doh, I misread the question, sorry about that!
If you're doing this on a sentence, capitalising the first letter of every word will not make it look 'correct', if that is what you're meaning to do. If it is, take a look into regular expression replaces.
penagate
Aug 4th, 2007, 08:41 AM
There are some user-created examples of functions for sentence casing on the strings page of the PHP.net manual.
http://php.net/manual/en/ref.strings
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.