|
Posted by IWT on 10/25/05 14:47
Ja NE wrote:
> when someone write some text in form's textarea and then
> enter
> new line (btw, is that \r or \n or combination?) I'm not "getting" that
> new line but space. what can I do to "recieve" and store (in mysql db)
> text with newlines instead of spaces. and, even better, to replace that
> newline with </p>\n<p>...
I've just done something very similar:
$description=$_POST['textarea'];
$description = strip_tags($description); // Remove any HTML tags
$description = "<p>".$description; // Add <p> to start
$description = str_replace("\r\n","</p><p>", $description); // Replace
new lines with paragraph
if(substr($description,-3)=="<p>") // Remove last <p> from description
$description = substr($description,0,-3);
Navigation:
[Reply to this message]
|