Preg_replace Кодирование
$html = preg_replace("/\s/u", "", $html);
Fantastic Ferret
$html = preg_replace("/\s/u", "", $html);