title: How to wrap string in span before and after all newlines in PHP?
body: <p>Upon searching I found PHP function that do inserts <br/> before all newlines in a string which is</p>
  
  <pre><code>nl2br();
  </code></pre>
  
  <p><strong>example:</strong></p>
  
  <pre><code>&lt;?php
     echo nl2br("This is an example\r\n where line breaks\r\n added", false);
  ?&gt;
  </code></pre>
  
  <p>Above code Output :</p>
  
  <pre><code>This is an example&lt;br\&gt;
  where line breaks&lt;br\&gt; 
  added
  </code></pre>
  
  <p>What I wanted to have output instead of &lt;br/&gt; I will wrap the string with the  tags before and after all newlines</p>
  
  <p><strong>example output from code above wrap string with span</strong></p>
  
  <pre><code>&lt;span&gt;This is an example&lt;/span&gt;
  &lt;span&gt;where line breaks&lt;/span&gt; 
  &lt;span&gt;added&lt;/span&gt;
  </code></pre>
  
  <p>Is there PHP function exist to this? or a custom PHP function</p>