I've encountered an oddity...the function somehow is either adding or retaining white space! Except for the
last array item every other array item has a break before the ending tag of the paragraph element in the final output.
I've modified the code a bit and have tried a few other things for the past couple hours trying to figure out where the phantom line break is coming from though no matter how much I tweak, adjust, remove, add, etc I can't seem to get any output without that line break. What am I missing here?
Code: Select all
function bb_4_n2p($pizza)
{
$pieces = explode("\n",$pizza);
foreach($pieces as $key => $value)
{
$value=str_replace(" ", " ", $value);
$value=str_replace("\n", "", $value);
$value=str_replace("\r", "", $value);
if (strlen($value)<2) {unset($pieces[$key]);}
}
foreach($pieces as $key => $value)
{
$bb_q = explode("<blockquote>",$value);
$bb_c = explode("<code>",$value);
if (count($bb_c)=='1' && count($bb_q)=='1')
{
$v2 = explode("\n",$value);
if (isset($result)) {$result .= '<p>'.$v2[0]."</p>\n\n";}
else {$result = '<p>'.$v2[0]."</p>\n\n";}
}
else
{
if (isset($result)) {$result .= $value."\n\n";}
else {$result = $value."\n\n";}
}
}
/*
$count = 0;
do
{
$pizza = str_replace("\n\n", "\n", $pizza, $count);
} while ($count > 0);
$result = '<p>'.str_replace("\n", "</p>\n\n<p>", $pizza).'</p>';
*/
//$result = '<p>'.preg_replace('/\n+/', "</p>\n\n<p>", $pizza).'</p>';
return $result;
}