Created
August 2, 2014 00:45
-
-
Save kevinquinnyo/f15389cb336b19645011 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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