word_censor()

word_censor($str, $censored[, $replacement = ''])

Parameters:
  • $str (string) – Input string
  • $censored (array) – List of bad words to censor
  • $replacement (string) – What to replace bad words with
Returns:

Censored string

Return type:

string

Enables you to censor words within a text string. The first parameter will contain the original string. The second will contain an array of words which you disallow. The third (optional) parameter can contain a replacement value for the words. If not specified they are replaced with pound signs: ####.

Example:

$disallowed = array('darn', 'shucks', 'golly', 'phooey');
$string = word_censor($string, $disallowed, 'Beep!');
doc_CodeIgniter
2016-10-15 16:32:47
Comments
Leave a Comment

Please login to continue.