php Replacing multiple spaces with a single space [duplicate]

This question already has answers here: How can I convert ereg expressions to preg in PHP? (4 answers) Closed 2 years ago. I’m trying to replace multiple spaces with a single space. When I use ereg_replace, I get an error about it being deprecated. ereg_replace(“[ \t\n\r]+”, ” “, $string); Is there an identical replacement for … Read more