Jump to content

How do you use newlines with textareas and php


Recommended Posts

I'm trying to input my string into a textarea however, newline characters don't seem to be splitting the data over multiple lines.  They do echo out into the textarea.  I read you need to use breaks with textareas and people suggest the nl2br function to convert newline characters to <br /> statements, however I notice when I use <br /> in my string they also just echo out in the textarea but don't do anything.  Am I missing anything.  Here's a sample:

 

            <textarea cols="200" rows="20">

            <?

            $text = "";

            $text .= '[HIDE]\n';

            $text .='File Name: ' . $nzb->getName() .'\n';

            $text .='Poster: ' . $nzb->getPoster() .'\n';

            $text .='Post Date: '. $nzb->getPostedDate() .'\n';

            $text .='Group:' . implode(',', $nzb->getGroups()) . '\n';

            $text .='File Size: ' . $size . 'MB' . '\n';

            $text .= '\n';

            $text .='Search: Engines';

            $text .='Binsearch\n';

            $text .='Newzleech\n';

            $text .='NZBIndex\n';

            $text .='NZBClub\n';

            $text .='Yabsearch\n';

            $text .='[/HIDE]\n';

            echo nl2br($text);

            ?>

            </textarea>

 

What's wrong with my code?

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.