Advertisement
Guest User

Untitled

a guest
Apr 23rd, 2019
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.36 KB | None | 0 0
  1. function flagWords(string $text, array $badwords): string
  2. {
  3. sort($badwords, SORT_STRING);
  4. $badword = reset($badwords);
  5. while ($badword) {
  6. $text = preg_replace(
  7. '/('. preg_quote($badword) .')/i',
  8. '<span style="color:red;">$1</span>',
  9. $text
  10. );
  11. $badword = next($badwords);
  12. }
  13.  
  14. return $text;
  15. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement