Created
June 4, 2011 01:38
-
-
Save burakerdem/1007450 to your computer and use it in GitHub Desktop.
PHP: ucwords() for UTF-8 strings
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
if (!function_exists('mb_ucwords')) | |
{ | |
function mb_ucwords($str) | |
{ | |
return mb_convert_case($str, MB_CASE_TITLE, "UTF-8"); | |
} | |
} |
Thanks, it helps me solve the problem of ucwords with Vietnamese UTF-8 strings
You have to mb_strtolower, before.
<?php
if (!function_exists('mb_ucwords'))
{
function mb_ucwords($str,$encoding='UTF-8')
{
return mb_convert_case(mb_strtolower($str, $encoding), MB_CASE_TITLE, $encoding);
}
}
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
It is not a replacement for ucwords