Hello, I'm working on advanced bad word filter and I was thinking about replacing SIMILAR words in the text. Such as example: - Bard word: 'shit' - Text: 'this is sh.it' or something else ... you get the point I guess. So, I would like to know how can I find the word "sh.it" and replace it with something else ... I know that function similar_text() in PHP exist and I know how to use it, but I can't figure it out, how to use it as search. Thanks!
No, there should be any other way to do it. Creating word-list takes too much time ... but thanks for idea.
Regarding the usage check out the documentation for examples... http://php.net/manual/en/function.similar-text.php http://www.php.net/manual/en/function.metaphone.php (another function which could be used). To replace similar words: What you could do is loop (foreach) through all the words (explode)...compare each word (using one or both of the above functions) to each one in the array (of bad words such as shit) if their similar replace them.
Thanks danx10, but I thought about that already. I just hoped there could be any other option. But what if I have two or more words to replace, and they need to be near each other, like for example: "shit eater"? I can't explode it and search for "shit" and "eater" since, I don't want to replace all "eater"s. Any good option how to simply that? I'll keep on trying.
Ok, I done it right this time. Exploding the words and looping is the right and I think the only way to do it. Thanks again!