you basically want to echo each line right ?
PHP Code:
$lines = explode("<br />", $code);
foreach($lines as $line)
{
echo $line;
echo "<br />";
}
your way is too complicated for what you want to do, but anyway here it is
PHP Code:
$codelen = strlen($code);
$nextline = strpos($code,'<br />');
while ( $nextline ){
$line = substr($code,0,$nextline);
echo '1LINE ' . $line . '<br />'; // TESTING
$code = substr($code,$nextline,$codelen);
echo '1CODE ' . $code . '<br />'; // TESTING
$nextline = strpos($code,'<br />');
echo 'NEXTLINE ' . $nextline . '<br />'; // TESTING
}
added the $codelen and changed the substr in the loop for the $code