How to check if letter is upper or lower in PHP?

后端 未结 13 1120
忘了有多久
忘了有多久 2020-12-04 19:12

I have texts in UTF-8 with diacritic characters also, and would like to check if first letter of this text is upper case or lower case. How to do this?

相关标签:
13条回答
  • 2020-12-04 20:06
    function starts_with_upper($str) {
        $chr = mb_substr ($str, 0, 1, "UTF-8");
        return mb_strtolower($chr, "UTF-8") != $chr;
    }
    

    Note that mb_substr is necessary to correctly isolate the first character.

    0 讨论(0)
提交回复
热议问题