By Alvin Alexander. Last updated: June 6, 2016
A PHP function that reduces multiple consecutive spaces in a string to one single space, so something like " " is reduced to " ".
function reduceMultipleSpacesToSingleSpace($text) { return preg_replace('/\s+/', " ", $text ); }