SHARE
TWEET

Untitled

zhpapazov Mar 7th, 2017 97 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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>
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top