Log in

View Full Version : Resolved Creeping Spaces



marain
12-21-2014, 05:15 PM
This query relates to the same code at issue in the recent thread "To Code a Line Break":

John provided suggested code that solved the problem completely:
echo "Comment of former client" . $testitable [$element] . "(file " . rtrim($testitable [$element + 1]) . "): “" . trim(preg_replace('"<br />[\x0d\x0a]*<br />[\x0d\x0a]*"', "<br />\n<br />\n“", $testitable [$element + 2])) ."”&nbsp;&nbsp;<br /><br />[For comments of other former clients, see our <a href='testimonials.php'>testimonials </a> page.]<br />"; // display accolade.In an effort to simplify, I tried to do the same thing using str_replace in lieu of preg_replace:
echo "Comment of former client" . $testitable [$element] . "(file " . $testitable [$element + 1] . "): “" . str_replace("<br />\x0d\x0a<br />", "<br />\x0d\x0a<br />“", trim($testitable [$element + 2])) . "”<br /><br />[For comments of other former clients, see our <a href='testimonials.php'>testimonials </a> page.]<br /><br />";My replacement code works, almost. The "almost" is that the replacement code causes insertion of an unwanted space immediately following insertion of quotation mark in all new paragraphs.

I am at a loss to see from where those unwanted spaces creep.

A.