Jump to content

How does the stripos() function work?


eldan88

Recommended Posts

I created a simple bad word function using stripos

 

function bad_word_filter($text, $bypass_write=false)

{

 

 

$patterns = array();

//bad words list

$patterns[0] = '****'; //Obviously bad words would go here

$patterns[1] = '****';

$patterns[2] = '****';

$patterns[3] = '****t';

 

 

foreach ($patterns as $check_for_word) {

if (stripos($text, $check_for_word) !== false) {

$bypass_write = true; // logica value to bypass write to dateabase check.

break;

}

}

 

return $bypass_write;

}

 

It's a basic function and simplistic bad words function (though I guess a person could make it more complex if he/she chooses), but it serves it's purpuse for me in my small cms webpage. Pretty neat little function this stripos is.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.