NOVINKA: Najžiadanejšie rekvalifikačné kurzy teraz s 50% zľavou + kurz AI ZADARMO. Nečakaj, táto ponuka dlho nevydrží! Zisti viac:

PHP - ucwords

Trieda

Koreň \ Bez triedy

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ázovDátový typPredvolená hodnotaPopis
$strstring

The input string.

$delimitersstring \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

      Aktivity