PHP get all unclosed HTML tags in string

MicroHellas

New Member
How can I get all the unclosed tags in a given string, prefferably in the order they should be closed?Note: consider that there are no errors in the HTML and that it was just cut off after X characters. No it's not a case of bad html or overlapping tags etc. Also there will be no ending Example:\[code\]<p><span>Lorem</span><b>ipsum\[/code\] ---return---> \[code\]</b></p>\[/code\]
-OR-
\[code\]<ul><li>1</li><li>2\[/code\] ---return---> \[code\]</li></ul>\[/code\]So that if the string is concatenated with the function output it will re-create a valid HTML.I'm not sure if a RegExp would do the trick here, basically I want to get anything that's between < and > that does not have a matching </ > closing tag.Thank you.
 
Back
Top