一半君的总结纸

听话只听一半君

#79 如何比较两个字符串(忽略大小写)?

首先对两个字符串使用 “tolower()” 或者”toupper()” 把他们都变成大写或者小写再比较:

string $a = "WindowsNT";
string $b = "windowsnt";

print ( $a == $b );
// Result: 0 //

print ( tolower( $a ) == tolower( $b ) );
// Result: 1 //

print ( toupper( $a ) == toupper( $b ) );
// Result: 1 //

13 January 2002

Advertisements

发表评论

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / 更改 )

Twitter picture

You are commenting using your Twitter account. Log Out / 更改 )

Facebook photo

You are commenting using your Facebook account. Log Out / 更改 )

Google+ photo

You are commenting using your Google+ account. Log Out / 更改 )

Connecting to %s

%d 博主赞过: