title: php function not returning string and how to remove line breaks
body: <p>Two issues with the below php function.</p>
  
  <p>One problem with the below function is the function echoes the $boo and $boo2 variables where the function is (i.e. before 1 and 2 is echoed). Both functions are echoed before 1 and 2. I'm unsure how to return the variables where each function is called without prematurely ending the function with 'return'.</p>
  
  <p>The $boo variables are single line breaks or paragraphs of text.</p>
  
  <pre><code>&lt;?php
  function listformat ($list) {
      $listformat = explode("\n", $list);
      echo '&lt;ul&gt;';
      foreach ($listformat as $line) {
          echo "&lt;li&gt;".$line."&lt;/li&gt;";
      };
      echo '&lt;/ul&gt;';
  };
  listformat($boo);
  echo '1';
  listformat($boo2);
  echo '2';
  ?&gt;
  </code></pre>
  
  <p>Also wondering how I can remove line breaks of the $boo variables within the function when the lines of text have more than 1 line break.</p>
  
  <p>EDIT: sample $boo is:</p>
  
  <blockquote>
    <p>aaaa  aaaaa</p>
    
    <p>bbb bbbb</p>
    
    <p>cccc c cc</p>
  </blockquote>
  
  <p>Sometimes it can have more or less line breaks in between.</p>