src/Drupal/Component/Utility/Unicode.php
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);
  }
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);
  }
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 ) ; }
Capitalizes the first character of each word in a UTF-8 string.

@param string $text
The text that will be converted.

@return string
The input $text with each word capitalized.

@ingroup php_wrappers
Capitalizes the first character of each word in a UTF - 8 string .