PHP Classes

File: example.php

Recommend this page to a friend!
  Classes of sk89q   Intelligent Censor   example.php   Download  
File: example.php
Role: Example script
Content type: text/plain
Description: Example
Class: Intelligent Censor
Replace rude words by acceptable alternatives
Author: By
Last change: Didn't display the result
Date: 15 years ago
Size: 712 bytes
 

Contents

Class file image Download
<?php
require_once "IntelligentCensor.php";

// * are not expanded
// % are expanded, and but they will only work when placed at either the
// beginning or ending of the word
$censors = array(
   
'*damn%' => 'darn',
   
'whore%' => 'people',
   
'bastard*' => 'happyperson',
   
'*ho' => 'person',
);
// Be careful about creating censors with wildcards, as they match more
// words than you may want.

// Can use * wildcards
$censors_exclusion = array(
   
'echo*',
);

$icensor = new IntelligentCensor($censors, $censors_exclusion);

echo
$icensor->censor("you're all DIETYDAMNING bastardly wHOres! you echo ho!");
// Result: you're all DARNING happyperson pEOples! you echo person!
//