On Sun, Mar 30, 2008 at 12:26 AM, Mary Anderson <maryfran@xxxxxxxxxxxxxxxxxx> wrote: > Hi all, > I have a php script which produces text which is to be displayed in > a textarea. I have the wrap for the text area set to 'hard'. I need to > have newlines inserted in the text. > "\n" and "<br>" don't work. They just get quoted literally in the > text. I suspect I need to use htmlspecialchars , but don't know what > special character to feed it. Sounds like you're using literal quotes here, Mary. Single quotes ('like this')take all data between them as literal, while double quotes ("like this") translate things within. $a = "Hello!"; $b = "I just wanted to say: $a"; $c = 'I just wanted to say: $a'; $d = "The quick brown fox jumped over the lazy dogs.\n"; $e = 'The quick brown fox jumped over the lazy dogs.\n'; The above will output as follows: $a: Hello! $b: I just wanted to say: Hello! $c: I just wanted to say: $a $d: The quick brown fox jumped over the lazy dogs. (with a newline) $e: The quick brown fox jumped over the lazy dogs.\n You may instead want to use HEREDOC syntax. $text =<<<EOT This will allow for actual newlines to be carried over. This also means that Windows-vs-Linux-vs-Mac newlines are translated exactly as they were entered, so if you're typing the data into the HEREDOC in a standard Windows environment, you'll have \r\n, whereas Linux will have \n, and Mac will have \r. Keep in mind, in a HEREDOC, those newline characters will not translate, but variables will. $b EOT; As always, if you want a newline after the final text is typed, include one full blank line after. And always end your HEREDOC by typing the signifier as the first character on the line. Sorry if this is "dumbing it down" for you, but I wanted to take the opportunity to not only address what may be your problem, but also put this tidbit into the archives with the question you asked, since someone down the road may very well find your question with that problem. ;-) -- </Daniel P. Brown> Forensic Services, Senior Unix Engineer 1+ (570-) 362-0283 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php