Deprecated: The each() function is deprecated. This message will be suppressed on further calls in /home/zhenxiangba/zhenxiangba.com/public_html/phproxy-improved-master/index.php on line 456
PHP: strncmp - Manual
[go: Go Back, main page]

PHP
downloads | documentation | faq | getting help | mailing lists | reporting bugs | php.net sites | links | conferences | my php.net

search for in the

strpbrk" width="11" height="7"/> <strncasecmp
Last updated: Thu, 31 May 2007

view this page in

strncmp

(PHP 4, PHP 5)

strncmp — 最初の n 文字についてバイナリ対応の文字列比較を行う

説明

int strncmp ( string $str1, string $str2, int $len )

この関数は、strcmp()に似てますが、 各文字列から(最大)文字数(len)を比較に使用 するところが異なります。文字列長がlenより も短い場合、その文字列の長さが比較に使用されます。

str1str2より小さ いに場合?< 0、str1str2より大きい場合に > 0 、等しい場合に 0 を返します。

比較は大文字小文字を区別することに注意してください。

preg_match()ereg()strcasecmp()substr()stristr()strcmp() および strstr() も参照ください。



add a note add a note User Contributed Notes
strncmp
Anonymous
17-Apr-2002 08:46
strncmp("sample","sam",4) returns 1 because the final requirement is if one string terminates before len, then the other must also terminate at that position. 

You can imagine that all your strings have one more final, invisible "termination" character.  If that termination character happens to be within in len, then it must match, too.

For instance, write that termination character with, say, the sequence "\0". Then you can equivalently consider that function call as strncmp("sample\0","sam\0",4).

So, the "p" in "sample" does not match the termination character in "sam".

strpbrk" width="11" height="7"/> <strncasecmp
Last updated: Thu, 31 May 2007
 
 
show source | credits | sitemap | contact | advertising | mirror sites