Hi there everyone,

I resolved the issue by replacing the function with:

$html_shipping_address= str_replace(array("\\r\\n", "\\r", "\\n"), "<br />", $shipping_address);

but I'm just curious as to why it might quit working. My guy told me that sometime in July, the script stopped converting the /r/n into <br> and searches gave me a lot of other people that had the same problem and I found my workaround as well through the search,, but I couldn't find any thread on an actual explanation why it quit working for them.

Could anyone shed some light on why it might have stopped working?

Any insight is greatly appreciated!

thanks,
json

    It didn't quit working.

    For one, "/r/n" as you stated is simply a forward slash, followed by an 'r', followed by a forward slash, followed by an 'n'. Another point is that the characters '\r\n' themselves are the same just with backslashes instead of forward slashes.

    However, place the character sequence "\r\n" inside of a double quote delimited string, and PHP will automatically replace those four characters with only two - namely a carriage return and a line feed.

    [man]nl2br/man operates on the latter - carriage returns and line feeds, not "\r\n". Your code above does not replace carriage returns and line feeds, it instead replaces the string '\r\n' or '\r' or '\n' with '<br />'. Your function does something completely different than what nl2br() is designed to do.

      Thanks very much for your help Brad, I went ahead and stuck with my resolution since although I now know it didn't quit working, the script didn't seem to care that it still worked and no longer wrapped the address(line breaks were visible in the database entry).

        schwim;10987202 wrote:

        (line breaks were visible in the database entry).

        Then it sounds like your data didn't have line breaks when you called nl2br() but instead had "\r\n", e.g. the line breaks were previously escaped elsewhere.

          Write a Reply...