Web >> Development >> PHP >> How to search and replace a pattern in a string----------------------------------------------------- $pattern = "/\s+/"; $replace = " "; $string = "quick brown fox"; $newstring = preg_replace($pattern,$replace,$string); $newstring becomes "the quick fox" |