Hello World!
` becomes `Hello World!`). * @return object A simplehtmldom object of the remaining contents. * * @todo Check if this implementation is still necessary, because simplehtmldom * already removes some of the tags (search for `remove_noise` in simple_html_dom.php). */ function sanitize( $html, $tags_to_remove = ['script', 'iframe', 'input', 'form'], $attributes_to_keep = ['title', 'href', 'src'], $text_to_keep = [] ) { $htmlContent = str_get_html($html); foreach ($htmlContent->find('*') as $element) { if (in_array($element->tag, $text_to_keep)) { $element->outertext = $element->plaintext; } elseif (in_array($element->tag, $tags_to_remove)) { $element->outertext = ''; } else { foreach ($element->getAllAttributes() as $attributeName => $attribute) { if (!in_array($attributeName, $attributes_to_keep)) { $element->removeAttribute($attributeName); } } } } return $htmlContent; } function sanitize_html(string $html): string { $html = str_replace('` tags. * * For example: * * ```HTML * * *