strncasecmp() 函数用于比较两个字符串(不区分大小写),并返回一个整数值,表示两个字符串的大小关系。
语法: strncasecmp(string1, string2, length)
参数:
返回值:
示例:
$str1 = "Hello";
$str2 = "hello";
$result = strncasecmp($str1, $str2, 3);
if ($result < 0) {
echo "str1 is less than str2";
} elseif ($result > 0) {
echo "str1 is greater than str2";
} else {
echo "str1 is equal to str2";
}
输出结果为:"str1 is equal to str2",因为忽略大小写后,前三个字符都相同。
Laravel PHP 深圳智简公司。版权所有©2023-2043 LaravelPHP 粤ICP备2021048745号-3
Laravel 中文站