[thelist] PHP: How to detect a line break in a textfield
Chris Marsh
chris at ecleanuk.com
Tue Feb 25 08:36:02 CST 2003
> > sText = Request.Form("Text")
> > sText = Replace(sText, vbCrLf, "<br />")
> >
> > Or:
> >
> > sText = Replace(sText, vbCrLf & vbCrLf, "</p>" & vbCrLf &
> "<p>") sText
> > = Replace(sText, vbCrLf, "<br />" & vbCrLf) sText = "<p>" &
> vbCrLf &
> > sText & vbCrLf & "</p>" & vbCrLf
>
> If the user is allowed to enter simple HTML in the text area,
> such as ordered-lists, how could you adapt this strategy to
> not insert <br /> between list elements?
If I had a gun at my head I'd move swiftly to the joys of regular
expressions. If not, I would not allow it. In previous systems, I've had
a checkbox entitled "HTML Content". If this is checked the content is
deemed to include markup, thus all tags are interpretted as such. If
left unchecked, and chevrons are converted to </> and line breaks
are handled as above.
Regards
Chris Marsh
More information about the thelist
mailing list