Advertisement
zero50x

Подсчёт повторяющихся слов в тексте (НЕДОДЕЛАНО)

Apr 12th, 2014
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.08 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8" />
  5. <title>Замена</title>
  6. </head>
  7.  
  8. <body>
  9. <?php
  10. /**
  11. * В этой переменно у нас хранится оригинальный переданый текст
  12. */
  13. $text = '';
  14. /**
  15. * Если нажата кнопка Добавить
  16. */
  17. if (isset($_POST['add'])) {
  18.  
  19. $text = strip_tags(trim($_POST['txt']));
  20.  
  21. $text = mb_strtolower($text, "UTF-8");
  22.  
  23. $clean = preg_replace('/[!~`@|.,:;?&)(\"><№#\\\%\\/^\'*$_]/u', '', $text);
  24.  
  25. // echo $clean; НЕ БУДЕМ ПОКАЗЫВАТЬ ОЧИЩЕННЫЙ ТЕКСТ
  26.  
  27. $massiv = explode(" ", $clean);
  28.  
  29. // echo $text;
  30.  
  31. print_r(array_count_values($massiv));
  32.  
  33. }
  34.  
  35.  
  36. /**
  37.  
  38. $text = preg_replace('/#[^a-zа-яё-]#i/u', '', $text);
  39.  
  40. $text = preg_replace('/\s\s+/', ' ', $text); УДАЛЯЕТ ЛИШНИЕ ПРОБЕЛЫ
  41. */
  42.  
  43. ?>
  44. <form method="post">
  45. Введите текст:<br/>
  46. <textarea cols="40" rows="10" name="txt"><?php echo $text; ?></textarea><br/>
  47. <input type="submit" name="add" value="Добавить" />
  48. <div>
  49. </div>
  50.  
  51.  
  52.  
  53. </form>
  54. </body>
  55. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement