Testing for the presence of HTML

From: Date: Tue, 20 Nov 2001 19:42:37 +0000
Subject: Testing for the presence of HTML
Groups: php.general 
Request: Send a blank email to php-general+get-75280@lists.php.net to get a copy of this message
My database contains a field which may or may not contain HTML code, depending on what a particular user enters when they enter the data. Here's the challenge: If there is HTML code in this field, then print the text with interpreted HTML. No problem at all. If there is no HTML code in the field, then I still want the data printed nice and neat; the users will probably use line returns to make their text look somewhat decent. So, assuming that $text contains the contents of this field, then what I want to do is this:
        if (!HTMLin$text) then $text = nl2br($text);
What's the best way to check and see if HTML is present in the field? Sliante, Richard S. Crawford http://www.mossroot.com AIM: Buffalo2K ICQ: 11646404 Y!: rscrawford MSN: underpope@hotmail.com "It is only with the heart that we see rightly; what is essential is invisible to the eye." --Antoine de Saint Exupéry "Push the button, Max!"

« previous php.general (#75280) next »