Venciity

Text Filter

Aug 21st, 2014
302
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.84 KB | None | 0 0
  1. <!doctype html>
  2. <html lang="en">
  3. <head>
  4.     <meta charset="UTF-8">
  5.     <title>Text Filter</title>
  6. </head>
  7. <body>
  8.     <form action="" method="post">
  9.         <label for="input">Text : </label>
  10.         <textarea name="inputText" id="input" cols="30" rows="5"></textarea>
  11.         <br/>
  12.         <label for="banList">banList : </label>
  13.         <input type="text" name="bannedWords" id="banList"/>
  14.         <br/>
  15.     </form>
  16.     <?php
  17.         if (isset($_POST['inputText']) && isset($_POST['bannedWords'])) {
  18.             $text = $_POST['inputText'];
  19.             $bannedWords = explode(", ", $_POST['bannedWords']);
  20.             foreach ($bannedWords as $bannedWord) {
  21.                 $text = str_replace($bannedWord , str_repeat('*' , strlen($bannedWord)), $text);
  22.             }
  23.             echo "<p>$text</p>";
  24.         }
  25.     ?>
  26. </body>
  27. </html>
Advertisement
Add Comment
Please, Sign In to add comment