<?php function filterwords(string $text, array $bannedWords) { return preg_replace( '/(?=\b(?:' . implode('|', $bannedWords) . ')\b)\w|\G(?!^)\w/i', '*', $text ); } echo filterwords("I am a dummy, but I'm not dumb", ['dummy']);
You have javascript disabled. You will not be able to edit any code.