PHP strncasecmp()関数
例
2つの文字列を比較します(大文字と小文字は区別されません)。
<?php
echo strncasecmp("Hello world!","hello earth!",6);
?>
定義と使用法
strncasecmp()関数は、2つの文字列を比較します。
注: strncasecmp()はバイナリセーフであり、大文字と小文字は区別されません。
ヒント:この関数はstrcasecmp()関数に似ていますが、 strcasecmp()にlengthパラメーターがない点が異なります。
構文
strncasecmp(string1,string2,length)
パラメータ値
Parameter | Description |
---|---|
string1 | Required. Specifies the first string to compare |
string2 | Required. Specifies the second string to compare |
length | Required. Specify the number of characters from each string to be used in the comparison |
技術的な詳細
戻り値: | この関数は次を返します。
|
---|---|
PHPバージョン: | 4.0.2 + |
その他の例
例
2つの文字列を比較します(大文字と小文字を区別しない= HelloとhELLoは同じものを出力します):
<?php
echo strncasecmp("Hello","Hello",6);
echo "<br>";
echo strncasecmp("Hello","hELLo",6);
?>
❮PHP文字列リファレンス