Removing the spacing from the output
<p>I have this code and it works absolutely fine when I do executions of the inputs individually but when you add the inputs in a loop, theres this extra spacing gets added between the last word. I cant find where that is coming from.</p>

<p>here is the code:</p>

<pre><code>function new($term)
{

    $exp = explode(" ", $term);

    sort($exp);

    foreach($exp as $val)
    {
        echo $val;
    }

}
</code></pre>

<p>This basically converts <code>"k duz q rc lvraw"</code>, into <code>"duzklvrawqrc"</code> only when you write <code>new("k duz q rc lvraw")</code></p>

<p>but if I have <code>$a = array("k duz q rc lvraw", "mybea zdr yubx xe dyroiy");</code>
and with the code</p>

<pre><code>foreach($a as $test)
{

new($test);
echo "\n";

}
</code></pre>

<p>The output comes out to be</p>

<pre><code>"duzklvraw
qrc"
</code></pre>

<p>and</p>

<pre><code>"dyroiy
mybeaxeyubxzdr"
</code></pre>

<p>This extra <code>"\n"</code> gets added, before the last few characters and at the end of the sentence and when you try to copy/paste it.. the lines are not consistent.</p>

<p>Why is this happening... this is the exact code!</p>
