PHP - ucwords
Trieda
Metóda - ucwords
(PHP 4, PHP 5, PHP 7)
The ucwords() function returns a string with the first character
of each word of a given string uppercased in case that first character was
alphabetic. This operation is sometimes called "capitalize" in other programming
languages.
**Note: ** The function is binary-safe. That means we can pass it binary data as well as text and it'll handle it correctly.
Procedurálne
- function ucwords (string $str, string $delimiters = \t\r\n\f\v) : string
Parametre
| Názov | Dátový typ | Predvolená hodnota | Popis |
|---|---|---|---|
| $str | string | The input string. | |
| $delimiters | string | \t\r\n\f\v | The optional delimiters which are used to define which character are the words separated by. |
Mávratovej hodnoty
Vracia: string
Returns a string with the first character of each word of a given string uppercased.
Príklady
$s = "these words have been uppercased";
$ucwords = ucwords($s); // capitalizing words using ucwords()
$s2 = "these_words_are_separated_by_an_underscore";
$ucwordsdelimiter = ucwords($s2, "_"); //the use of delimiter
echo $ucwords;
echo '</br>';
echo $ucwordsdelimiter;
Súvisiace manuály
- function strtolower (string $string) : string
- function ucfirst (string $str) : string
