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?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.