Downloads
Stars
Version
Making HTML clean since late 2012!
composer require timgws/cleanhtml
use timgws\CleanHTML\CleanHTML;
$tidy = new CleanHTML();
$output = $tidy->clean('<p><strong>I need a shower. I am dirty HTML.</strong>');
$output should now contain:
<h2>I need a shower. I am dirty HTML.</h2>
Using the Clean function will remove tables, any Javascript or other non-friendly items that you might not want to see from user submitted HTML.
If you want to see some examples, the best place to look would be some of the CleanHTML test
<br />
tags with paragraph tags<script>
tags<h1>
tags to <h2>
<p><strong>
tags to <h2>
<h2><strong>
with just <h2>
tags<p><span>
tags