Advertisement
zhpapazov

Untitled

Mar 7th, 2017
209
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.67 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.  
  12. <?php
  13. if (isset($_GET['input'])) {
  14. $input = $_GET['input'];
  15. $input = preg_split('/[.!\/\s]+/', trim($input), -1, PREG_SPLIT_NO_EMPTY);
  16. $input = array_map('strtolower', $input);
  17. $inputCountValues = array_count_values($input);
  18. $output = <<<HTML
  19. <table border="2">
  20. HTML;
  21. foreach ($inputCountValues as $key => $value) {
  22. $output .= "<tr><td>$key</td><td>$value</td></tr>";
  23. }
  24. $output .= <<<HTML
  25. </table>
  26. HTML;
  27. echo $output;
  28. }
  29. ?>
  30. </body>
  31. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement