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

后端 未结 13 1147
忘了有多久
忘了有多久 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 19:56

    Use ctype_upper for check upper case:

    $a = array("Word", "word", "wOrd");
    
    foreach($a as $w)
    {
        if(ctype_upper($w{0}))
        {
            print $w;
        }
    }
    

提交回复
热议问题