3v4l.org

run code in 300+ PHP versions simultaneously
<?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']);

preferences:
31.1 ms | 405 KiB | 5 Q