"ENTP" "ISTP"这2个字符串,我要统计两者中相同字符的个数,请问怎么做?在线等!
谢谢!
------解决方案--------------------
- PHP code
$str1="ENTP";
$str2="ISTP";
$count=0;
for($i=0;$i<strlen($str1);$i++){
if($str1{$i}==$str2{$i})
$count++;
}
echo $count;
$str1="ENTP";
$str2="ISTP";
$count=0;
for($i=0;$i<strlen($str1);$i++){
if($str1{$i}==$str2{$i})
$count++;
}
echo $count;