string a line to new line and do not add newline at the end?
<p>I have a string </p>

<pre><code>$str = 'aaaaabbbbbcccccdddddeeeeefffffggggghhhhhjjjjj';

$pos = 0;
$tmp = 0;
while($pos&lt;strlen($str)) {
  $tmp  .= substr($str,$pos,5)."\n";
  $pos += 5; 
}
</code></pre>

<p>I dont want to add a <code>"\n"</code> at the end of produced <code>$str</code></p>

<pre><code>aaaaa
bbbbb
ccccc
ddddd
eeeee
fffff
ggggg
hhhhh
jjjjj //No new line here
</code></pre>
