thanks for your help.
I edited your version a bit but it's still not working 100%
Basically waht I want is to check for the badwords and if a badword is found I set $filtered=1
can you help me fix. I see the variable matches is changing but when I tried to set filter it's not working. what am i doing wrong?