<?php function filterwords(string $text, array $bannedWords) { return preg_replace_callback( '/\b(?:' . implode('|', $bannedWords) . ')\b/iu', fn($m) => str_repeat('*', mb_strlen($m[0])), $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.