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.
You could use the array_intersect() function of php It returns all intersections. So if it does return more than 2, you return true.
But it doesnt accept string elements as input, so you would need to fill an array with the chars of the string you want to compare.
Manual: http://php.net/manual/de/function.array-intersect.php
look at
similar_text()
. The following code is untested but i think it would work as you want.