Can anybody tell me how do i convert newline character to space.
I tried str_replace to find \n but that does not work, because the string does not show \n at all. I even tried converting nl2br and then str_replace of <br /> or <br> to space, but still it does not work.

    • [deleted]

    $new_string = preg_replace("/\n/"," ",$old_string);

      Vincent is the man with this Regular Expression sheit. 😃

        Could it be that the new lines are stored as \r instead of \n?

        In that case:

        $new_string = preg_replace("/\n|/\r/"," ",$old_string);

        Is that the correct syntax bor both?

        -David

          Thanks to everybody. This was of much help to me.

            • [deleted]

            Allmost, remember that if newlines are '\r\n', then "/\n|\r/" will replace the \r with a space, AND the \n with a space. that makes two spaces.....

              Write a Reply...