- $html = preg_replace('~\s*<p>\s*~', '', $html);
- $html = preg_replace('~\s*</p>\s*~', '<br />', $html);
- $html = preg_replace('~<br />$~', '', $html);
- return $html;
+ $html = preg_replace('~\s*<p>\s*~u', '', $html);
+ $html = preg_replace('~\s*</p>\s*~u', '<br />', $html);
+ $html = preg_replace('~(<br\s*/?>)+$~u', '', $html);
+ return trim($html);