]*)[^>]*>(.*?)!s', '!<([^>]*/|\!--[^>]*--|\?[^>]*\?)>!' ); $to=array('$2', ''); while (!isset($tmp) || ($code != $tmp && $code=$tmp)) $tmp=preg_replace($from, $to, $code); $lines=explode("\n", $code); $err_count=0; foreach ($lines as $num=>$line) { if (preg_match_all('!<([^> ]*)[^>]*>!', $line, $m, PREG_PATTERN_ORDER)) { foreach ($m[1] as $tag) { $err_count++; echo 'line '.($num+1).': un'.($tag{0} != '/' ? 'clos' : 'open')."ed tag $tag
"; } } } if ($err_count > 0) echo "Found $err_count bad tags!
"; else echo 'The code is okay..
'; ?>