Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

APPLE199's avatar

Hide "bad words" in all views that have values from database?

Hi guys.

Is there a way to hide all "bad words" or censor them with **** when loading them? Say for instance there are all commends and I don't want to do a regex or something else to censor a comment because I have over 50 views with different variables and data etc.

So if the bad word is "stupid" and the comment says "You are stupid", it will be "You are ******". Is there a way to do this with Laravel?

Thanks guys!

0 likes
1 reply
jekinney's avatar
Level 47

Only way I know how server side is to see if a word is in an array of bad words if true replace it. It's better performance wise to check on input to the data base.

Or use JavaScript to check a word after each spacebar press.

Or both.

Either way isn't going to be 100% but effort is there. Google around you can find lists of bad words as an array.

Two second Google for php bad word filter brought http://banbuilder.com

3 likes

Please or to participate in this conversation.