RE: [PHP] Large text fields

From: Date: Thu, 02 Nov 2000 10:21:59 +0000
Subject: RE: [PHP] Large text fields
Groups: php.general 
Request: Send a blank email to php-general+get-23365@lists.php.net to get a copy of this message
No, <pre></pre> would output the whole paragraph in a single line each. I use (for articles) a class, that uses RegEx changing every "\n" (more then juts \n - newline) to "\n<BR>" and every "\n<BR> (spaces, tabs, newlines) \n<BR>" \n\n<P> in this way the output look real cool and the database can be reused just by a simple substring() of <BR> and <P> 's. I input it like this already in the database since RegEx are slow and because I like to make HTTP request some faster. Here's the class I use: I think you can easily figure out how to use it: If got any problems do not hesitate to ask me. (might not reply till next Monday) Cheers! <? /* * Article Organizer * Filters Plain/Text looking for newlines replacing them eventually into it's HTML equivalents. * * COPYRIGHT * Copyright (C) 2000, * Maxim Maletsky, [maxim.maletsky@lincmedia.co.jp], * LINC Media Inc., J-Door.com, J@pan Inc. * * LICENSE * This software is FREEWARE. Do with it what you want to, as long as * the copyright notice remains intact. * * DISCLAIMER * Do not blame me for anything that my software could do wrong. * It's a FREE software - respect it! * * If you redistribute this code please mention in your script my info (Name & Email) as it's creator. * If you are using this code please send me your feedback and your improvements to it. */ class max_Organizer { var $nl="\010\013\015"; var $ws=" \n\t\v"; var $data_return = array(); function HTML($data) { // $data = eregi_replace("<(p|br)>", '', $data); $data = nl2br($data); $data = eregi_replace("[$this->nl]", "\n", $data); $data = eregi_replace("\n*<br>\n*", "<BR>\n", $data); $data = ereg_replace("<BR>[\n$this->ws(<BR>)]*<BR>\n*", "\n\n<P>", $data); $data = str_replace(' ', ' &nbsp;', $data); return $data; } function Filter($data) { $data = htmlentities($data); if (floor(phpversion())<4) $data = addslashes($data); return $data; } function In($data='') { if(is_array($data)) { for($i=0; $i<sizeof($data); $i++) $data_return[$i] = $this->Filter(trim($data[$i])); } else { $data_return = trim($data); $data_return = $this->Filter($data_return); } return $data_return; } function Out($data='') { if(is_array($data)) for($i=0; $i<sizeof($data); $i++) $data_return[$i] = stripslashes($this->HTML(trim($data[$i]))); else $data_return = stripslashes($this->HTML(trim($data))); return $data_return; } function Single($data='') { // $data = eregi_replace("<(p|br)>", '', $data); $data = $this->Filter(trim($data)); $data = $this->HTML($data); return $data; } } ?> -----Original Message----- From: Russell Barr [mailto:rbarr@quik.com] Sent: Thursday, November 02, 2000 4:52 PM To: Claus Nybo; php-general@lists.php.net Subject: Re: [PHP] Large text fields Use <pre></pre> tags around the output Russell > Hi, > > I am working on a website using php3 and mySQL. On one page in the site > administration is inputting new articles, via a form, with fields such as > $title, $date, $article, etc. These are then passed to mySQL, to be viewed > on another page by users. > > This all works fine, except for the text of the article itself. When the > text is typed in to the textfield on the form, it exist of several > paragraphs, with blank lines in between, but when it is viewed from the > database on another page all the paragraph breaks and blank lines are gone, > and all the text is displayed in just one long continued block. > > What do I do to preserve the format in which the text is typed? With the > different paragraf breaks and blank lines? > > Thanks for the help! > > Claus > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net > For additional commands, e-mail: php-general-help@lists.php.net > To contact the list administrators, e-mail: php-list-admin@lists.php.net > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net For additional commands, e-mail: php-general-help@lists.php.net To contact the list administrators, e-mail: php-list-admin@lists.php.net

« previous php.general (#23365) next »