{ucwords:string}

Description

Uppercases the first character of every word in a string, leaving the rest of each word untouched - the AA wrapper around PHP ucwords(). Words are separated by whitespace only (spaces, tabs, newlines), so text joined by a hyphen or an apostrophe counts as a single word and only its very first letter is capitalized. It does not lowercase the other letters, so an already-uppercase word stays uppercase; pipe the text through strtolower first if you want clean Title Case. It is ASCII-only: accented first letters (an e-acute, for example) are left unchanged - use ucfirst, which is Unicode-aware, when the first letter may be accented. The input is not trimmed.

Parameters

string required default (empty)

The text to convert. Each word in it gets its first character uppercased; the rest of each word is left untouched. Words are separated by whitespace only (space, tab, newline), so text joined by a hyphen or apostrophe counts as one word. ASCII letters only: accented first letters (for example an e-acute) are left as they are. The string is not trimmed.

Examples

virtual{ucwords:eric is here}
Expected(accented first letters unchanged; e-acute eric stays lowercase, Is Here is capitalized)
ActualEric Is Here
ucwords is the byte-based PHP function, not a Unicode-aware one. It uppercases ASCII a-z only. A word whose first letter is accented (for example an e-acute in eric) keeps its lowercase accented letter. For accent-correct capitalization of the first letter use {ucfirst:} instead, which is UTF-aware. (With a real accented input, an e-acute eric stays eric while is here becomes Is Here.)
test{ucwords:hello world}
ExpectedHello World
ActualHello World
The everyday use: uppercase the first letter of every word. Each space-separated word starts with a capital.
test[{ucwords:}]
Expected[]
Actual[]
With no string, ucwords returns an empty string. The brackets here just make the empty result visible.
test{ucwords:mary o brien-smith}
ExpectedMary O Brien-smith
ActualMary O Brien-smith
Only whitespace separates words. A hyphen or an apostrophe does not start a new word, so brien-smith is one word and only its b is capitalized. Names like OBrien or Brien-Smith need extra handling.
test{ucwords:hello WORLD}
ExpectedHello WORLD
ActualHello WORLD
ucwords touches only the first character of each word. The rest of a word is left exactly as it was, so an already-uppercase WORLD stays WORLD. To force lowercase elsewhere, combine with {strtolower:} first.
test{ucwords:the quick brown fox}
ExpectedThe Quick Brown Fox
ActualThe Quick Brown Fox
A common pattern: turn a plain sentence or a stored title into Title Case for display. Note this capitalizes every word, including small words like the or of.
test{ucwords:123 main street}
Expected123 Main Street
Actual123 Main Street
A word whose first character is not a letter (a digit, here) is left as-is; the next letter inside it is not capitalized. The following words still get title-cased.