the problem is here:
for ($bbnr = 0; $bbnr <= 14; ++$bbnr)
{
$dirtydescription = str_replace($bb[$bbnr], $html[$bbnr], $productdescription);
$clean_description = $dirtydescription;
}
In first run you use '$product'
result is in '$dirty' .. $product stays the same all the time!
Next run uses $product .. to make a new version of $dirty = The first is OVERWRITTEN
.. also put: $clean = $work_var AFTER (outside of) loop
try this way to use SAME variable within the LOOP
$html[] = "<ul>";
$html[] = "</ul>";
$work_var = $productdescription; // leave the original intact, just in case
// loop
for ($bbnr = 0; $bbnr <= 14; ++$bbnr)
{
$work_var = str_replace($bb[$bbnr], $html[$bbnr], $work_var);
}
// new version to display
$clean_description = $work_var;
// display
echo $productdescription; // let us compare with original input
echo '<br />';
echo $clean_description;