title: php nl2br not working with output of passthru and shell_exec
body: <p>I have a program (written in cpp) which outputs some text lines. Each line starts on a new line. On the commandline this program works well. To test the code I used both <code>fprintf (stdout, "some text\n");</code> and <code>'cout &lt;&lt; "some text" &lt;&lt; endl;'</code> to produce newlines.  </p>
  
  <p>When I use <code>passthru</code> or <code>shell_exec</code> in a php-script, the newlines disappear - as expected - in my webbrowser. The newlines do appear when I use curl, though (which is good):</p>
  
  <pre><code>   $command = "/home/test/myprogram 2&gt;&amp;1";
     $data = shell_exec ( $command );
     echo $data;
  </code></pre>
  
  <p>To print the newlines in the webbrowser, I tried lots of php code to replace newlines with <br> tags, but nothing seems to work, including examples from a related SO question (<a href="https://stackoverflow.com/questions/7929975/php-new-line-not-working">PHP New Line Not Working</a>): </p>
  
  <pre><code>   echo nl2br($data);
     echo str_replace(array("\r\n","\r","\n"),'&lt;br&gt;',$data);
  </code></pre>
  
  <p>I guess the failure has to to with my usage of <code>passthru</code> or <code>shell_exec</code>, but I can't figure how to solve my issue.</p>