Thu, December 2, 2021
 
https://devcodepro.comdevcodepro
X
InterServer Web Hosting and VPS
Home · Latest · Trends
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: 2180  / 5 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
Login with Google
 
Share
Posted
jimmy
Member since Dec 15, 2016
Total Code Snippets: 16
Total Comments: 2
Location: n/a
jimmy snippets
5 years ago, mon, dec 5, 16, 1:47:20
comments: 1 / hits: 4582
PHP
5 years ago, mon, jan 9, 17, 2:50:09
comments: 1 / hits: 28372
PHP
5 years ago, mon, jan 16, 17, 2:18:41
comments: 1 / hits: 2983
PHP
5 years ago, sat, jan 21, 17, 5:41:42
comments: 0 / hits: 4101
PHP
5 years ago, fri, feb 10, 17, 12:02:07
comments: 1 / hits: 2803
PHP
5 years ago, tue, feb 28, 17, 9:40:06
comments: 0 / hits: 2020
PHP
5 years ago, sun, mar 5, 17, 1:51:18
comments: 1 / hits: 5452
PHP
5 years ago, thu, mar 16, 17, 5:51:45
comments: 1 / hits: 2128
PHP
5 years ago, sun, apr 16, 17, 3:44:59
comments: 1 / hits: 7688
CSS