Case-insensitive UTF-8 string comparison. This is a UTF8-aware version of strcasecmp.
$compare = UTF8::strcasecmp($str1, $str2);
integer Core_UTF8::strcasecmp( string $str1 , string $str2 )
参数列表
参数 类型 描述 默认值 $str1
string
String to compare $str2
string
String to compare
integer
less than 0 if str1 is less than str2integer
greater than 0 if str1 is greater than str2integer
0 if they are equalpublic static function strcasecmp($str1, $str2)
{
if ( UTF8::is_ascii($str1) && UTF8::is_ascii($str2) ) return strcasecmp($str1, $str2);
$str1 = UTF8::strtolower($str1);
$str2 = UTF8::strtolower($str2);
return strcmp($str1, $str2);
}