Home Menu

ucwords

Uppercase the first character of each word in a string

Syntax

ucwords ( string $str [,  string $delimiters = " \t\r\n\f\v"  ] ) : string

Parameters

str

The input string.

delimiters

The optional delimiters contains the word separator characters.

"\t" ASCII 9 (0x09) a tab
"\n" ASCII 10 (0x0A) a new line (line feed)
"\v" ASCII 11 (0x0B) a vertical tab
"\f" ASCII 12 (0x0C) a form feed
"\r" ASCII 13 (0x0D) a carriage return
" " ASCII 32 (0x20) an ordinary space

Return

Returns the modified string.

Examples

1

<?

$str = "hello world!";

$return = ucwords($str);

echo $return;

?>
Hello World!

2

<?

$str = "hello|world!";
$delimiters = "|";

$return = ucwords($str, $delimiters);

echo $return;

?>
Hello|World!

3

<?

$str = "case\tcase\ncase\vcase\fcase\rcase case";
$delimiters = " \t\r\n\f\v";

$return = ucwords($str, $delimiters);

echo $return;

?>
Case    Case
CaseCaseCase
Case Case

4

<?

$str = "case#case%case&case,case'case|case";
$delimiters = "#%&,'|";

$return = ucwords($str, $delimiters);

echo $return;

?>
Case#Case%Case&Case,Case'Case|Case

5

<?

$str = "case\tcase\ncase\vcase\fcase\rcase case#case%case&case,case'case|case";
$delimiters = " \t\r\n\f\v#%&,'|";

$return = ucwords($str, $delimiters);

echo $return;

?>
Case    Case
CaseCaseCase
Case Case#Case%Case&Case,Case'Case|Case

PHP

JesusBible
HTMLCSSJSPHPSVGMore
AboutTerms