php - 如何检查字母在PHP中是大写还是小写?

标签 php string utf-8

我也有带有变音符号的 UTF-8 文本,并且想检查该文本的第一个字母是大写还是小写。如何做到这一点?

最佳答案

function starts_with_upper($str) {
    $chr = mb_substr ($str, 0, 1, "UTF-8");
    return mb_strtolower($chr, "UTF-8") != $chr;
}

请注意,mb_substr 是正确隔离第一个字符所必需的。

Working Demo Online

关于php - 如何检查字母在PHP中是大写还是小写?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2814880/

相关文章:

php - 搜索查询速度慢,基于 View 的记录集。如何加快速度?

php - 将 xml 字符串逐字转储到 mysql 数据库

string - 如何检查字符串是否包含 dart 中的主题标签?

java - Android Java 日历 getDisplayName/s 返回 null

c - url在c中编码一个utf-8字符串?

java - 比较两个在字典顺序上相同但在字节级别不相同的字符串

php - 严重性 : 8192 Message: Methods with the same name as their class will not be constructors in a future version of PHP;

PHP设置下拉框的选中值

PHP URLDecode/UTF8_Encode 字符集特殊字符问题

php - Laravel Mysql 查询选择条件