Blogger Information
Blog 13
fans 0
comment 0
visits 5501
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
字符串 比较函数
安之若素
Original
799 people have browsed it

实例

<?php
echo '<h2>字符串函数二</h2> <hr color="#00CC00">';

/**
*1 strcmp($str1,$str2);
*2 strncmp($str1,$str2,$length);
*3 strcasecmp($str1,$str2);//不区分大小写
*4 strspn() //拆分
*5 strcspn()//组合
*/ 

$name1='xiaoli小李';
$name2='XIAOli小李';
//1.strcmp ($name1,$name2)二个字符串如相等返回0 大于》0 《0
echo strcmp($name1,$name2)==0 ? '相等':'不相等','<br/>';
//2.strncmp($name1,$name2 $length)比较开头部分指定长度是否想等 
echo strncmp($name1,$name2,3)==0 ? '相等':'不相等','<br/>';
//3. strcasecmp($name1,$name2) ,不区分大小写 
echo strcasecmp($name1,$name2)==0 ? '相等':'不相等','<br/>';
echo'<hr color="#00CC00">';
//strspn($str ,$mark,$start,$length)
//计算字符串 中全部字符都存在于指定字符集合的第一段子串的长度
echo strspn('13799840793','0123456789').'<br/>';
echo  strspn('13799840793','0123456789',5,5).'<br/>';
echo'<hr color="#00CC00">';
//匹配手机号
$iphone ='57545454454';
$mark ='0123456789';
echo strspn($iphone,$mark)? $iphone:$mark;
?>

运行实例 »

点击 "运行实例" 按钮查看在线实例


Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post