Alright this has always confused me like I am sure it has many other coders... how would I go about searching through something like "this is damn cool" and then take out the word damn? so it would just return "this is cool"
Thanks for your time - Dan
$var= preg_replace('/damn/','',"this is damn cool');
you can tweak the regular expression to get the extra space out
thank you.. how would I do it for multiple words in the same line of code?
Pass preg_replace an array of the regexps you want to match (e.g., '/damn/' would be one of them).
Why fire up the REGEXP engine when you don't even need it?
$words = array('damn','fuck','shit','ass'); for($i = 0; $i < count($words); $i++) { str_replace($words[$i],'',$string); }