Expand|Select|Wrap|Line Numbers
- <!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>
- <title>Compare Strings</title>
- </head>
- <body>
- <h1>Compare Strings</h1><hr />
Expand|Select|Wrap|Line Numbers
- <?php
- if (isset($_GET['first_string'] && isset($_GET['second_string'])) {
- $FirstString = $_GET['first_string'];
- $SecondString = $_GET['second_string'];
- if (FirstString == $SecondString)
- echo "<p>Both Strings are the same</p>";
- else {
- echo "<p>Both have "
- . similar_text($FirstString, $SecondString)
- . " character(s) in common.<br />";
- echo "<p>You must change " . levenshtein($FirstString, $SecondString) ."
- character(s) to make the strings the same.<br />";
- }
- }
- else
- echo "<p>Enter two strings you want to compare.</p>";
- ?>
Expand|Select|Wrap|Line Numbers
- <form action="CompareStrings.php" method="get" enctype="application/x-www-form-urlencoded">
- <p>First String <input type="text" name="first_string" size="20" value="<?php if
- (!empty($_GET['first_string'])) echo $_GET['first_string'] ?>" /></p>
- <p>Second String <input type="text" name="second_string" size="20" value="<?php if
- (!empty($_GET['second_string'])) echo $_GET['second_string'] ?>" /></p>
- <p><input type="submit" value="Compare Strings" />
- </form><hr />
- </body>
- </html>