note 41299 added to function.strip-tags

From: Date: Tue, 06 Apr 2004 02:50:17 +0000
Subject: note 41299 added to function.strip-tags
Groups: php.notes 
Request: Send a blank email to php-notes+get-67682@lists.php.net to get a copy of this message
Self-closing tags - i.e. XHTML tags that use the XML self-closing tag format. I was baffled that Test A did not work - it uses "<br />". Eventually, I found Test B)-1 was the answer - specifiy "<br>". The problem with Test B)-1, is I am using strip_tags to help make output XML-compilant! I want to keep "<br />" (XML-compliant self-closing tag); I want to kill "<br>" (invalid XML when there's no corresponding "</br>"); echo strip_tags("I want to keep br tag<br />Line 2.", '<br />'); # # Test A) output is "I want to keep br tagLine 2." # strip_tags removed "<br />", despite saying in 2nd param to # strip_tags to "keep the <br />" tag!! $text = strip_tags("I want to keep br tag<br />Line 2<br>Line 3.", '<br>'); echo $text; # Test B)-1 output is "I want to keep br tag<br />Line 2<br>Line 3. # strip_tag kept all "<br />", "<br>" etc occurances! Good! # am actually using strip_tags("", "<a><p><b><br>"); so I _need_ strip_tags $text = preg_replace("/(<br>)/i", "<br />", $text); echo $text; # Test B)-2 output: I want to keep br tag<br />Line 2<br />Line 3. # Finally, it's all OK. ---- Manual Page -- http://www.php.net/manual/en/function.strip-tags.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+41299 Delete -- http://master.php.net/manage/user-notes.php?action=delete+41299&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+41299&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#67682) next »