Oihana PHP

ucWords.php

Table of Contents

Functions

ucWords()  : string
Uppercases the first letter of each word in a string (multibyte-safe).

Functions

ucWords()

Uppercases the first letter of each word in a string (multibyte-safe).

ucWords(string $source) : string

A word starts at any letter that is not preceded by a letter or a digit, so words separated by spaces, punctuation or symbols are all handled. The rest of each word is left untouched.

Parameters
$source : string

The input string.

Tags
example
use function oihana\core\strings\ucWords;

echo ucWords( 'hello world' )   ; // "Hello World"
echo ucWords( 'foo-bar baz' )   ; // "Foo-Bar Baz"
echo ucWords( 'éric à paris' )  ; // "Éric À Paris"
author

Marc Alcaraz (ekameleon)

since
1.0.9
Return values
string

The string with the first letter of each word upper-cased.

On this page

Search results