It's not easy - You can do it using regular expressions as I've mentioned above. The tricky part is that you have to dynamically generate the matching expression - alone that could easily turn into quite a few lines of code, since you have to define the words, separate them out, ensure that all characters that mean something are escaped, etc. (addslashes() wouldn't do it, unfortunately)
If you don't understand regex, go get the camel book - O'Reilly's Perl book - and read chapter 7: "Regular Expressions". This is far and away the best explanation of regex I've ever seen.
If it's worth doing, it's worth spending $15 and getting this book!
-Ben