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

后端 未结 13 1146
忘了有多久
忘了有多久 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:58

    Tried ?

    $str = 'the text to test';
    if($str{0} === strtoupper($str{0})) {
       echo 'yepp, its uppercase';
    }
    else{
       echo 'nope, its not upper case';
    }
    

提交回复
热议问题