Skip to content

Instantly share code, notes, and snippets.

@kevinquinnyo
Created August 2, 2014 00:45
Show Gist options
  • Save kevinquinnyo/f15389cb336b19645011 to your computer and use it in GitHub Desktop.
Save kevinquinnyo/f15389cb336b19645011 to your computer and use it in GitHub Desktop.
<?php
// more efficient way to do this than creating an array of all permutations indexed by each value and comparing to eachother?
$array = [ 'asdfasdfasdf_X', 'asdfasdfasdf_Y', '123412341234_X', 'asdfasdfasdf_Z', '123412341234_Y', 'dsfjiowefnilknml' ];
$permutations = [];
for($i=0; $i<count($array); $i++) {
$key = array_shift($array);
$permutations[$key] = $array;
$array[] = $key;
}
foreach($permutations as $key => $array) {
foreach($array as $value) {
similar_text($key, $value, $percent);
if($percent > 70) {
echo "$key and $value have a match percent greater than 70: $percent%\n";
}
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment