任何简单的方法来检查两个或多个字符是否相等,当比较四个字符串? [英] Any easy way to check if two or more characters are equal when comparing a four character string?

查看:157
本文介绍了任何简单的方法来检查两个或多个字符是否相等,当比较四个字符串?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我必须比较两个字符串,如 INTU IXTE ,并检查两个或多个字符是否一样。对于前两个字符串,我想返回 true ,因为I和T是相同的。

I have to compare two strings such as INTU and IXTE and check if two or more of the characters are the same. With the previous two strings, I'd want to return true, since the I and the T are the same.

字符串中的字母顺序不相关,因为每个字符不能出现在字符串的不同位置。似乎应该有一个简单的方法来做到这一点。

Order of letters in the string ends up being irrelevant as each character can not appear in different positions in the string. It seems like there should be an easy way to do this.

推荐答案

查看 similar_text()。以下代码未经测试,但我认为它可以按您的需要工作。

look at similar_text(). The following code is untested but i think it would work as you want.

$a = "INTU";
$b = "IXTE";

$is_match = ( similar_text($a , $b) >= 2) ;

这篇关于任何简单的方法来检查两个或多个字符是否相等,当比较四个字符串?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆