You are here: Re: new lines in form « PHP Programming Language « IT news, forums, messages
Re: new lines in form

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]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация