How would I make the start of every new word a capital letter?PHP Code:$words="a sentence";
echo $words;
edit: found out, cant make post resolved.
Printable View
How would I make the start of every new word a capital letter?PHP Code:$words="a sentence";
echo $words;
edit: found out, cant make post resolved.
It does help to post the resolution so that other people with your problem/question can have the knowledge to fix it also.
PHP Code:$words = strtoupper("a sentence");
echo $words;
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.
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.
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