public static Unicode::ucwords($text)
Capitalizes the first character of each word in a UTF-8 string.
string $text: The text that will be converted.
string The input $text with each word capitalized.
public static function ucwords($text) { $regex = '/(^|[' . static::PREG_CLASS_WORD_BOUNDARY . '])([^' . static::PREG_CLASS_WORD_BOUNDARY . '])/u'; return preg_replace_callback($regex, function(array $matches) { return $matches[1] . Unicode::strtoupper($matches[2]); }, $text); }
© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!lib!Drupal!Component!Utility!Unicode.php/function/Unicode::ucwords/8.1.x