note 41299 deleted from function.strip-tags by nlopess

From: Date: Fri, 09 Apr 2004 19:29:29 +0000
Subject: note 41299 deleted from function.strip-tags by nlopess
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-67917@lists.php.net to get a copy of this message
Note Submitter: Falkirk Rebus ---- 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.

« previous php.notes (#67917) next »