title: Remove trailing newline
body: <p>I've a MySQL database from which I extract a string which is a list of words separated by newline. Now I want to remove only the trailing
  newline.</p>
  
  <p>I tried using preg_replace as</p>
  
  <pre><code>$string = preg_replace('/\n/','',$string);
  </code></pre>
  
  <p>It works, but all the newlines in the strings are removed :(</p>
  
  <p>How can I do this?</p>