[ View menu ]

Monthly Archive May, 2008

Replacing whole words in strings in PHP

May 15, 2008

I was recently tasked with creating a simple dirty word filter in PHP that relies on our blacklist of about 600 words. The filter should simply replace the word with its character length in asterisks.
My first attempt just used str_replace, but I quickly realized that even dirty words embedded in clean words would […]