|
Posted by Alan Little on 06/07/06 00:24
Carved in mystic runes upon the very living rock, the last words of
Wayne of comp.lang.php make plain:
> $a = $_POST['txt_content']; # txt_content = This is a<CR><LF>Test
> $p = str_replace ("%0D%0A", "<br>", $a);
>
> That is the above code that I am using, however, it is not picking up
> the CR/LF from the textarea.
Try $p = str_replace ("\r\n", "<br>", $a);
However, depending on what OS and/or browser your visitors use, a new
line character might be passed as CR, LF or CRLF. I usually do something
like:
$p = ereg_replace("\r\n?" "\n", $a);
$p = str_replace("\n", '<BR>', $p);
The first line makes sure they're all LFs before converting them to BRs.
--
Alan Little
Phorm PHP Form Processor
http://www.phorm.com/
Navigation:
[Reply to this message]
|