Find if a html tag was closed

From: Date: Tue, 26 Mar 2002 02:31:51 +0000
Subject: Find if a html tag was closed
Groups: php.general 
Request: Send a blank email to php-general+get-90140@lists.php.net to get a copy of this message
Hi all, I am trying to build a regex to check if an array of allowed html tags were closed. For example: Wrong: <b>text</a> Should give me something like: Tag <b> was not closed. Here's what I came up so far: $tags_to_check = Array('a','b','i','p'); foreach ($tags_to_check as $tag_check) { if (eregi("<". $tag_check . ">(.*)[^</" . $tag_check . ">]",$_POST['form_field'])) { ?> Tag <?php echo htmlentities('<' . $tag_check . '>'); ?> not closed <?php } } I know there's some optimization that also could be done regarding the foreach loop, but I haven't come up with any solutions. Any help is appreciated, since I promised to myself to learn regex tonight :-) Thanks, -- Julio Nobrega.

« previous php.general (#90140) next »