]*>#i', "\n", $html) ?? $html; $text = html_entity_decode(strip_tags($text), ENT_QUOTES | ENT_HTML5, 'UTF-8'); $text = preg_replace('/[ \t]+/', ' ', $text) ?? $text; $text = preg_replace("/\n{3,}/", "\n\n", $text) ?? $text; return trim(implode("\n", array_map('trim', explode("\n", $text)))); } }