ucwords

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.

"\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 = "case case";

$return = ucwords($string);

echo $return;

?>
Case Case

2

<?

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

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

echo $return;

?>
Case|Case

3

<?

$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

<?

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

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

echo $return;

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

5

<?

$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

lcfirst

ucfirst

addcslashes

addslashes

bin2hex

chop

chr

chunk_split

convert_uudecode

convert_uuencode

count_chars

crc32

crypt

echo

explode

fprintf

get_html_translation_table

hebrev

hebrevc

hex2bin

html_entity_decode

htmlentities

htmlspecialchars

htmlspecialchars_decode

implode

join

lcfirst

levenshtein

localeconv

ltrim

md5

md5_file

metaphone

nl_langinfo

nl2br

number_format

ord

parse_str

print

printf

quoted_printable_decode

quoted_printable_encode

quotemeta

rtrim

setlocale

sha1

sha1_file

similar_text

soundex

sprintf

sscanf

str_contains

str_ends_with

str_getcsv

str_ireplace

str_pad

str_repeat

str_replace

str_rot13

str_shuffle

str_split

str_starts_with

str_word_count

strcasecmp

strchr

strcmp

strcoll

strcspn

strip_tags

stripcslashes

stripos

stripslashes

stristr

strlen

strnatcasecmp

strnatcmp

strncasecmp

strncmp

strpbrk

strpos

strrchr

strrev

strripos

strrpos

strspn

strstr

strtok

strtolower

strtoupper

strtr

substr

substr_compare

substr_count

substr_replace

trim

ucfirst

vfprintf

vprintf

vsprintf

wordwrap

PHP

Home Menu