Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html>
- <head>
- <title>Word Mapping</title>
- </head>
- <body>
- <form method="get">
- <input type="text" name="input">
- <input type="submit">
- </form>
- <?php
- if (isset($_GET['input'])) {
- $input = $_GET['input'];
- $input = preg_split('/[.!\/\s]+/', trim($input), -1, PREG_SPLIT_NO_EMPTY);
- $input = array_map('strtolower', $input);
- $inputCountValues = array_count_values($input);
- $output = <<<HTML
- <table border="2">
- HTML;
- foreach ($inputCountValues as $key => $value) {
- $output .= "<tr><td>$key</td><td>$value</td></tr>";
- }
- $output .= <<<HTML
- </table>
- HTML;
- echo $output;
- }
- ?>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement