John, the original problem arose on account of my inability to communicate to my text editor (Notepad) that I wanted to search for hard returns. When I entered a hard return that I wanted interpreted as part of a search string character, the text editor interpreted it instead as a hard return end of line. You solved that problem by suggesting that, in place of hard returns, I should use hexadecimal ascii replacement characters, i.e. "\x0d\x0a\x0d\x0a".
Your solution made my php code do exactly what I wanted it to do. Part of your solution, however, was to replace str_replace with preg_replace. On reviewing your solution, I speculated that, using your hexadecimal ascii substitutions, I ought to be able to implement your solution more simply by using str_replace. I attempted to do that. More particularly, in place of
PHP Code:
trim(preg_replace('"<br />[\x0d\x0a]*<br />[\x0d\x0a]*"', "<br />\n<br />\n“", $testitable [$element + 2]));
I used
PHP Code:
trim(str_replace("\x0d\x0a\x0d\x0a", "\x0d\x0a\x0d\x0a“", $testitable [$element + 2]));
My substitution yields strange results. More particularly, what it causes is to not begin text following two hard returns with two hard returns followed by “ (open quote). Rather, what it causes is to append two “'s at the end of $testitable [$element + 2], regardless of whether that element contains zero, one, or more than one double hard return. You can see those incorrect results at http://www.njexpungements.com/test.php .
I believe I'm getting closer in my quest for simplification, but I'm obviously not there yet. So my question is, must I use preg_replace, or can I accomplish the same thing with str_replace? In the meanwhile, as mentioned above, your suggested code is (to use your term) serviceable, for which you have my continuing thanks.
A.
Bookmarks