I have one string, called $a[0] . I have 10 other strings, called $a[1] all the way up to $a[10] (so 10 more vars - 11 in total).
Let's say:
$a[0] = 'abcdabcdabcd';
$a[1] = 'aabbaabbaab';
$a[2] = 'abcabcabcabc';
$a[3] = 'dcbadcbadcba';
$a[4] = 'abccabcdaccd';
// and the remaining variables are also random, using only abcd and having the same # of letters
How can I compare the $a[0] with the other vars to see which ones match the closest (and taking the order of the letters into consideration as well)? For example, $a[4] is obviously closest to $a[0], because it's the same thing, except for the 2 characters that have been changed to 'c' instead. The other strings surely have more than 2 differences, so they are ruled out and $a[4] will be taken as the closest one.
How can I do this using PHP?
Thanks in advance! 🙂