public static function Unicode::ucwords in Service Container 7.2
Same name and namespace in other branches
- 7 lib/Drupal/Component/Utility/Unicode.php \Drupal\Component\Utility\Unicode::ucwords()
Capitalizes the first character of each word in a UTF-8 string.
Parameters
string $text: The text that will be converted.
Return value
string The input $text with each word capitalized.
File
- lib/
Drupal/ Component/ Utility/ Unicode.php, line 382 - Contains \Drupal\Component\Utility\Unicode.
Class
- Unicode
- Provides Unicode-related conversions and operations.
Namespace
Drupal\Component\UtilityCode
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);
}