Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function flagWords(string $text, array $badwords): string
- {
- sort($badwords, SORT_STRING);
- $badword = reset($badwords);
- while ($badword) {
- $text = preg_replace(
- '/('. preg_quote($badword) .')/i',
- '<span style="color:red;">$1</span>',
- $text
- );
- $badword = next($badwords);
- }
- return $text;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement