i've been using str_replace( to replace cuss words with **** on my guest book. This works ok, but i dont want it to be case sensitive, is another function i can use instead of str_replace( that isent case sensitive?
a quick search of php.net's documentation resulted in this little snip of code:
function stri_replace($old, $new, $haystack){ return preg_replace('/'.quotemeta($old).'/i', $new, $haystack); }
RTFM! 😉
Actually the function is str_ireplace() not stri_replace() see str_ireplace() and look at the first comment concerning use with version of PHP less than 5.0 While the code above might if fact work, if you use PHP 5 then go ahead and use it, but if not the comment pretty much makes a function that is way too much, I would at least try the suggested function as it is much simpler.