Show Source Code
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<!--
The Chinese Zodiac
Amy Tavakouli
May 21, 2014
index.php
-->
<title>Similar Names</title>
<link href="ChineseZodiac.css" rel="stylesheet" type="text/css" media="screen, projection" />
<meta name="Description" content="Chinese Zodiac">
<meta name="keywords" content="Chinese Zodiac">
</head>
<body>
<div class="container">
<div class="header">
<?php include("includes/inc_header.php"); ?>
</div>
<div class="content"><br /><br />
<h1>Similar Names</h1><hr />
<?php
$SignNames = array("Rat", "Ox", "Tiger", "Rabbit", "Dragon", "Snake", "Horse", "Goat", "Monkey", "Rooster", "Dog", "Pig");
$LevenshteinSmallest = 999999;
$SimilarTextLargest = 0;
for ($i = 0; $i < 11; ++$i) {
for ($j = $i + 1; $j < 12; ++$j) {
$LevenshteinValue = levenshtein($SignNames[$i], $SignNames[$j]);
if ($LevenshteinValue < $LevenshteinSmallest) {
$LevenshteinSmallest = $LevenshteinValue;
$LevenshteinWord1 = $SignNames[$i];
$LevenshteinWord2 = $SignNames[$j];
}
$SimilarTextValue = similar_text($SignNames[$i], $SignNames[$j]);
if ($SimilarTextValue > $SimilarTextLargest) {
$SimilarTextLargest = $SimilarTextValue;
$SimilarTextWord1 = $SignNames[$i];
$SimilarTextWord2 = $SignNames[$j];
}
}
}
echo "<p>The levenshtein() function has determined that "$LevenshteinWord1" and
"$LevenshteinWord2" are the most similar names.<?p>\n";
echo "<p>The similar_text() function has determined that "$SimilarTextWord1" and
"$SimilarTextWord2" are the most similar names.</p>\n"
?>
<hr />
</div>
<div class="footer">
<?php include("includes/inc_footer.php"); ?>
</div>
</div>
</body>
</html>