FULL STACK   ·   UI   ·   UX   ·   GRAPHICS   ·   DEVELOPER   ·   INSTRUCTOR

Adam Khoury

Donate funds to show love and support

Click the button below to donate funds securely online. You can use your PayPal account or a credit card.

Your donations help free up my time to produce more content and assist in covering server costs. It's also a great way to say thanks for the content!

Application Configuration

Adam will be adding options here soon.

Bad Word Filter Function and Harmful Character String Array Replace

Published :
Author :
Adam Khoury
Learn to build bad word or harmful character filter functions and data filtration systems for user input. We are using the str_ireplace() php function fed with arrays. <?php function badWordFilter($data){ $originals = array("douche","punch","damn"); $replacements = array("friend","love","wow"); $data = str_ireplace($originals,$replacements,$data); return $data; } $myData = "Hi douche, damn I want to punch you for a good cause!"; $cleaned = badWordFilter($myData); echo $cleaned; ?>