3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?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);
based on 6OllW
Output for 5.3.4 - 7.2.0
string(37) " M\u212Bllorca Urlaub Spass Spannung"
Output for 4.3.0 - 5.3.3
string(42) "  M\u212Bllorca  Urlaub Spass Spannung"