Jump to content
xisto Community
Sign in to follow this  
Azeri_boy

Sos...sos...help Me Pls. Help to filter bad words

Recommended Posts

I should filter bad words and replace them with three dot. I know this is not so difficult to write function for such purpose. But function that I wrote doesn't give any result neither necessary result nor error. May be you know what's going wrong with my function.

Code:

<?php

$abuse_list=array("abuse","bad");

function filter_bad_words($s)

{

global $abuse_list;

foreach($abuse_list as $k=>$v)

{

eregi_replace("^".$v."$","...",$s);

}

return $s;

}

$s="abuse, badness, bad word";

echo filter_bad_words($s);

?>

_linenums:0'><?php$abuse_list=array("abuse","bad");function filter_bad_words($s){global $abuse_list;foreach($abuse_list as $k=>$v){ eregi_replace("^".$v."$","...",$s);}return $s;}$s="abuse, badness, bad word";echo filter_bad_words($s);?>

Thanks beforehand.

 

The problem was in the way of using function eregi_replace() must be so:

$s=eregi_replace($v,"...",$s). RegEx patern also was incorrect. I had hurryed.

In general filter bad words is not good idea. :lol:

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | 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.