Jesus · Bible · HTML · CSS · JS · PHP · SVG · Applications

ucwords

Description

The ucwords of String for PHP uppercase the first character of each word in a string.

Syntax

ucwords(
    string $string,
    string $separators = " \t\r\n\f\v"
): string

Parameters

string

The input string.

separators

The optional separators contains the word separator characters.

StringASCIIDescription
"\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 · string

<?

$string = "case case case";

$return = ucwords($string);

echo $return;

?>
Case Case Case

2 · separators · |

<?

$string = "case|case|case";
$separators = "|";

$return = ucwords($string, $separators);

echo $return;

?>
Case|Case|Case

3 · separators · \t\r\n\f\v

<?

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

$return = ucwords($string, $separators);

echo $return;

?>
Case    Case
CaseCaseCase
Case Case

4 · separators · #%&,'|

<?

$string = "case#case%case&case,case'case|case";
$separators = "#%&,'|";

$return = ucwords($string, $separators);

echo $return;

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

5 · separators · \t\r\n\f\v#%&,'|

<?

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

$return = ucwords($string, $separators);

echo $return;

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