Convert Text to Titlecase by PHP

If you want to convert text to titlecase, you can use this function:

$string_in_titlecase = mb_convert_case($str, MB_CASE_TITLE, "UTF-8");

$str is the string, that should get converted to titlecase, $string_in_titlecase is the converted string.