Jump to content

PHP function that removes unclosed html tags


Recommended Posts

Hello, i'm wondering how to remove all unclosed tags like below

<a href='<mysite'>Yeooeoeoo //Remove this<ul><li>Oh no this has links too..</li> //Keep working tags</ul>

I'm not sure does strip_tags(); remove them.

Link to comment
Share on other sites

strip_tags may display strange behavior with invalid markup, it might remove too much. Finding invalid HTML like that isn't a trivial task because there are a ton of possible edge cases, but I'm sure there's a regular expression that can do most of it.



Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Create New...