Originally Posted by djm0219
$original = 'This had 5 spaces';
$fixed = str_replace(' ',' ',$original);
Doing that it doesn't matter if there is one space or 5 spaces. They will all be changed to a required space.
This will also replace all spaces which may not be desired.
Your original data will still be stored with the number of spaces you require. Don't store them with the HTML non-breaking space. You use the preformat CSS to retain them in HTML since it ignores multiple whitespace.