当前位置: 动力学知识库 > 问答 > 编程问答 >

need capitalize words with special chars in PHP

问题描述:

ucwords doesn't capitalize foreign chars like öüäõ

so I need a solution, which will make "öösel" into "Öösel"

Is there a simple way to do it with regexp or I have to check all the characters manually?

网友答案:

If you have the mbstring extension installed, you can use the mb_convert_case function, specifying MB_CASE_TITLE as the $mode parameter.

网友答案:

You can give a try to strtoupper() which works fine for me with French.
Sorry I hadn't seen it was ucwords...

Otherwise, this should work:

mb_convert_case($string, MB_CASE_TITLE, "UTF-8");

网友答案:

Aside from the other answers, which suffer from the same problems as ucwords, you might take a look at keeping this variation in your toolbox.

分享给朋友:
您可能感兴趣的文章:
随机阅读: