Tidy HTML before passing to PHP, not after