title: Passing TextArea to php comes out as one line string
body: <p>I'm at a bit of a loss on how to get this to work, as not really a PHP person. </p>
  
  <p>basically in my form, I have a TextArea in my HTML, where a user will paste in a TraceRoute from their command line. This then get's passed to my PHP form (where it's turned into xml...this is unimportant). </p>
  
  <p>However, the tracert is coming out as one single lined string, as opposed to individual lines. This makes it very difficult to read. </p>
  
  <p>So I need a way for the traceroute to be displayed exatly as it is in the TextArea box. </p>
  
  <p>Here is my html code (submit.html)</p>
  
  <pre><code>&lt;html&gt;
  &lt;body&gt;
  &lt;form action="convert2xml.php" method="post"&gt;
  Traceroute:
  &lt;textarea rows="5" cols="50" name="Traceroute"&gt;&lt;/textarea&gt;
  &lt;br&gt;
  &lt;input type="Submit"&gt;
  &lt;/form&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>And here is my PHP file which handles the data (convert2xml.php).</p>
  
  <pre><code>&lt;html&gt;
  &lt;body&gt;
  &amp;#60;Information&amp;#62;
  Traceroute output:
  &lt;br&gt;
  &lt;?php echo $_POST["Traceroute"]; ?&gt; &amp;#60;/Information&amp;#62;
  &lt;br&gt;
  </code></pre>
  
  <p>As you can see the &lt; and > have been replaced with the html codes, this is what turns it into a nice XML layout (in this case it is in a xml tag called Information). </p>
  
  <p>An example input would be (i've redacted some of the IP's and domains):</p>
  
  <pre><code>    C:\Users\******&gt;tracert 8.8.8.8
  
      Tracing route to google-public-dns-a.google.com [8.8.8.8]
      over a maximum of 30 hops:
  
        1     1 ms     3 ms     1 ms  192.168.0.1
        2    12 ms    12 ms     8 ms  **.**.**.**
        3     9 ms    12 ms     9 ms  **.**.**.**
        4    13 ms    13 ms    13 ms  example-doman.name [**.**.**.**]
        5    15 ms    15 ms    14 ms  example-doman.name [**.**.**.**]
        6    12 ms    14 ms    13 ms  **.**.**.**
        7    14 ms    13 ms    16 ms  **.**.**.**
        8    11 ms    19 ms    15 ms  google-public-dns-a.google.com [8.8.8.8]
  
      Trace complete.
  </code></pre>
  
  <p>But what i am getting is one continous string:</p>
  
  <pre><code>&lt;Information&gt;C:\Users\******&gt;tracert 8.8.8.8 Tracing route to google-public-dns-a.google.com [8.8.8.8] over a maximum of 30 hops: 1 1 ms 3 ms 1 ms 192.168.0.1 2 12 ms 12 ms 8 ms **.**.**.** 3 9 ms 12 ms 9 ms **.**.**.** 4 13 ms 13 ms 13 ms example-doman.name [**.**.**.**] 5 15 ms 15 ms 14 ms example-doman.name [**.**.**.**] 6 12 ms 14 ms 13 ms **.**.**.** 7 14 ms 13 ms 16 ms **.**.**.** 8 11 ms 19 ms 15 ms google-public-dns-a.google.com [8.8.8.8] Trace complete. &lt;/Information&gt;
  </code></pre>
  
  <p>I've looked into nl2br, but this doesn't help me, as i would have to input the "\n" manually at the end of the traceroute line to get it to work. </p>
  
  <p>The only thing i can think of, would be a loop where it checks the string for the ascii new line code, and then adds a "\n" or &lt; br >. Or would something line adding " " around each line in text area, and then getting html to add &lt; br > at each "? </p>
  
  <p>But there must be some easier method of doing it? Any Ideas?</p>
  
  <p>************UPDATED*********</p>
  
  <p>Correct answer provided by @FastTurtle</p>
  
  <p>Seems i was over complicating it. </p>
  
  <p>n2lbr works perfect for my purpose. </p>
  
  <p>Here is the updated PHP:</p>
  
  <pre><code>    &amp;#60;Information&amp;#62;
      &lt;?php echo nl2br($_POST["Traceroute"]); ?&gt; &amp;#60;/Information&amp;#62;
  </code></pre>
  
  <p>And here is the output now:</p>
  
  <pre><code>&lt;/Information&gt;C:\Users\******&gt;tracert 8.8.8.8
  
  Tracing route to google-public-dns-a.google.com [8.8.8.8]
  over a maximum of 30 hops:
  
  1 1 ms 3 ms 1 ms 192.168.0.1
  2 12 ms 12 ms 8 ms **.**.**.**
  3 9 ms 12 ms 9 ms **.**.**.**
  4 13 ms 13 ms 13 ms example-doman.name [**.**.**.**]
  5 15 ms 15 ms 14 ms example-doman.name [**.**.**.**]
  6 12 ms 14 ms 13 ms **.**.**.**
  7 14 ms 13 ms 16 ms **.**.**.**
  8 11 ms 19 ms 15 ms google-public-dns-a.google.com [8.8.8.8]
  
  Trace complete. &lt;/Information&gt;
  </code></pre>