To calculate the percentage of similarity between two strings without depending on the order of the parameters and be case insensitive, I use this function based on levenshtein's distance:
<?php
// string similarity calculated using levenshtein
static function similarity($a, $b)
{
return 1 - (levenshtein(strtoupper($a), strtoupper($b)) / max(strlen($a), strlen($b)));
}
?>
This will always return a number between 0 and 1, representing the percentage, for instance 0.8 represents 80% similar strings.
If you want this to be case-sensitive, just remove the strtoupper() functions.