Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums Back End br to newline trouble

  • This topic is empty.
Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #30886
    mbarandao
    Member

    Good day all:

    I’ve been experiencing a great difficulty resolving a problem concerning replacing


    to an actual newline inside a textarea box. Much of the problem has been because the data in the textarea is populated via a php script in this manner:

        echo "formObj.servicedesc.value = '".toSafeString($inf["servicedesc"])."';n"; 

    Inside my textarea box I get the following:


    ";

    Whereas, my ideal outcome is:

    On 12/01/10 @ 09:51
    We performed the following:

    information update

    ----End of Service Report----

    On 12/01/10 @ 09:43
    We performed the following:

    information update

    ----End of Service Report----

    On 11/29/10 @ 11:55
    We performed the following:

    Information update

    ----End of Service Report----

    My textarea box is written in html as follows:

    I have used numerous preg_replace functions but unable to resolve. I’m think I may be placing it incorrectly.

    Any assistance is greatly appreciated!
    Mossa

    #71026
    mbarandao
    Member

    Great news! Adding the following function to my php

    function toSafeString($string) {
    $string = str_replace('
    ', "n", $string); //this in particular
    $string = preg_replace('/[rn]/s', '\n', $string);
    return $string;
    }

    the issue has been resolved! it was in particular the first $string.

    To all of the great experts on this forum, I’m most appreciative for your selfless time.

    The Best,
    Mossa

    #70996
    TheDoc
    Member

    Glad you got it sorted without any help! Always feels a little better that way!

Viewing 3 posts - 1 through 3 (of 3 total)
  • The forum ‘Back End’ is closed to new topics and replies.