php中常用的字符串比较函数strcmp()实例解释
int strcmp ( string $str1 , string $str2 )
以二进制方式进行比较
以该函数比较时区分大小写
返回值,如果str1小于str2返回<0,如果str1大于str2返回>0如果两者相等返回0。
<?php$str1="helloworld";//$str1与$str3的值相等$str2="HELLOWORLD";$str3="helloworld";//$str1与$str3的值相等echostrcmp($str1,$str2);//输出1echostrcmp($str2,$str1);//输出-1echostrcmp($str1,$str3);//输出0?>
还有个函数strcasecmp(),用法与strcmp()类似,只是不区分大小写而已,这里不再啰嗦了
声明:本站所有文章资源内容,如无特殊说明或标注,均为采集网络资源。如若本站内容侵犯了原著者的合法权益,可联系本站删除。