]*)[^>]*>(.*?)!s', '!<([^>]*/|\!--[^>]*--|\?[^>]*\?)>!' ); $to=array('$2', ''); while (!isset($tmp) || $code != $tmp) { if (isset($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)) { for ($i=1; $i != 2; $i=2) { foreach ($m[$i] as $tag) if ($tag != '') { $err_count++; echo 'line '.($num+1).': un'.($i == 1 ? 'clos' : 'open').'ed tag '.htmlspecialchars($tag).'
'; } } } } if ($err_count > 0) echo "Found $err_count bad tags!
"; else echo 'The code is okay..
'; list($usec, $sec) = explode(' ', microtime()); echo ((float)$usec + (float)$sec - $start) . '
'; ?>