zhpapazov

Untitled

Mar 7th, 2017
157
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.64 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <title>Word Mapping</title>
  5. </head>
  6. <body>
  7. <form method="get">
  8. <input type="text" name="input">
  9. <input type="submit">
  10. </form>
  11. </body>
  12. </html>
  13.  
  14. <?php
  15. if (isset($_GET['input'])) {
  16. $input = $_GET['input'];
  17. $input = preg_split('/[.!\/\s]+/', trim($input));
  18. $input = array_map('strtolower', $input);
  19. $inputCountValues = array_count_values($input);
  20. $output = <<<HTML
  21. <table border="2">
  22. HTML;
  23. foreach ($inputCountValues as $key => $value) {
  24. $output .= "<tr><td>$key</td><td>$value</td></tr>";
  25. }
  26. $output .= <<<HTML
  27. </table>
  28. HTML;
  29. echo $output;
  30. }
  31. ?>
Advertisement
Add Comment
Please, Sign In to add comment