Checking For Duplicates…

Duplicate check includes a name similarity check, points similarity check (within +/- 5% total), type (triathlon/duathlon) check, and date match check.
'2009-01-01'"; $results = mysql_query($sql) or die(mysql_error()); echo "Processing races…
"; $arr_Races = array(""); $arr_Duplicates = array(""); $match_count = 0; $i = 0; while($row = mysql_fetch_array($results)) { // build an array that we can loop through. We will need to then duplicate this $arr_Races[$i] = $row; $i++; } $arr_Races_Match = array(""); $arr_Races_Match = $arr_Races; foreach ($arr_Races AS $race) { // DEBUG: which UIDs are we processing //echo ("RACE_UID: ".$race[uid].". ".$race[name]."
"); $j = 0; foreach ($arr_Races_Match AS $match) { if ($race[uid] != $match[uid]) { similar_text($race[name], $match[name], $percent); if ($percent >= 90 && ($race[points]/$match[points]*100) >= 95 && ($race[points]/$match[points]*100) <= 105 && (date("Ymd", $race[date]) == date("Ymd", $match[date])) && (!in_array($match[uid], $arr_Duplicates)) && ($race[type] == $match[type])) { if ($j == 0) { echo ("RACE_UID: ".$race[uid].". ".$race[name]." [".$race['points']." Points]
"); $j = 1; array_push($arr_Duplicates, $race[uid]); } // DEBUG: which USERUID are we processing echo ("     POTENTIAL MATCH: ".$match[uid].". ".$match[name]." [".$match['points']." Points] (".round($percent,0)."%)
"); $match_count++; } } } } echo "Done processing races.
"; echo $match_count." potential duplicates found."; //header('Location: https://slowtwitch.com/calendar/?tags_cleared='.$tags_cleared.'.php'); ?>