3
PHP replace bad words
PHP replace bad words function / form
<?php
//myform.php
function badWordsReplace($censored) {
$words = array("this","tutorial","sucks");
for($i = 0; $i <= sizeof($words); $i++) {
$censored = str_replace(@$words[$i],"-!!censored!!-",$censored);
}
return $censored;
}
if(isset($_POST['submit'])) {
$title = $_POST['title'];
echo badWordsReplace($title);
} else {
?>
<form method="post" action="myform.php">
<input type="text" value="this tutorial sucks" name="title">
<input type="submit" name="submit" value="Submit">
</form>
<?php } ?>
rated 3 times
(3)
(0)
comments: 0 / hits: 1844
/ 4 years ago, fri, feb 10, 17, 12:15:34
More From
» PHP
Comments
There are no comments for this Snippet yet
Only authorized users can post. Please sign in first, or register a free account