/** * Makes the first character of every word in a UTF-8 string uppercase. * This is a UTF8-aware version of [ucwords](http://php.net/ucwords). * * $str = UTF8::wpucwords($str); * * @author Harry Fuecks <*****@*****.**> * @param string $str mixed case string * @return string */ public static function wpucwords($str) { if (UTF8::is_ascii($str)) { return ucwords($str); } return preg_replace_callback('/(?<=^|[\\x0c\\x09\\x0b\\x0a\\x0d\\x20])[^\\x0c\\x09\\x0b\\x0a\\x0d\\x20]/u', function ($matches) { return UTF8::wpstrtoupper($matches[0]); }, $str); }