valid xhtml enforcer for user-contributed content

This aint no validator. Oh, and it's written in PHP. If you wish to comment on this sucker in a more public setting or read a better description of what exactly is going on here, knock yourself out in the CSS Help Pile thread on the topic.
This function was created to echo out any invalid XHTML passed through it; if any errors exist they are returned, otherwise the function returns null. If anyone has any code suggestions, or if you find any bugs, I'm all ears.

Additional code would need to be added to the XHTMLvalid function to escape tags such as <hr />, <br />, etc.. Using the PHP function nl2br() when echoing the output would void having to worry about <br />. If you're wondering about &amp; URL invalidation, there is a separate function for that which would also be called on comment output, but right now that seems to create more problems than it solves.

Errors Will Appear Below:

Allowable Tags:

* For example purposes only, strip_tags code not included in function below. In this example the PHP strip_tags() function is called before the XHTMLvalid function is called with the following tag set: <strong><em><a><strike><pre>.

The Function:

* Watch for line breaks