- var_dump: documentation ( source)
- preg_replace: documentation ( source)
<?php
// remove duplicated spaces into single spaces but persist special spaces like the non-breaking-space
$normalized = " \xC2\xA0M\u212Bllorca\xC2\xA0 Urlaub \nSpass\xE2\x80\x88Spannung";
$normalized = preg_replace("/([ \xC2\xA0])?\\s+/u", '$1 ', $normalized);
$normalized = preg_replace('/(\s) +/u', '$1', $normalized);
var_dump($normalized);