cant replace \n

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • windandwaves

    cant replace \n

    Hi Folk

    I am getting some data from an html form (textarea). I am having trouble
    with replacing line breaks in the data with spaces.

    here is my line:

    trim(stripslash es(str_replace( "\n", ' ',
    (htmlentities($ _POST["facexp"]))))));

    I end up with lots of   but the linebreaks are still there.

    What am I doing wrong?

    Thank you

    - Nicolaas


  • Chris Hope

    #2
    Re: cant replace \n

    windandwaves wrote:
    [color=blue]
    > I am getting some data from an html form (textarea). I am having
    > trouble with replacing line breaks in the data with spaces.
    >
    > here is my line:
    >
    > trim(stripslash es(str_replace( "\n", ' ',
    > (htmlentities($ _POST["facexp"]))))));
    >
    > I end up with lots of   but the linebreaks are still there.
    >
    > What am I doing wrong?[/color]

    IIRC line breaks from an html textarea are supposed to be done with \r\n
    so you'd want to str_replace("\r \n\", '&nbsp', ...

    --
    Chris Hope | www.electrictoolbox.com | www.linuxcdmall.com

    Comment

    • windandwaves

      #3
      Re: cant replace \n

      Chris Hope wrote:[color=blue]
      > windandwaves wrote:
      >[color=green]
      >> I am getting some data from an html form (textarea). I am having
      >> trouble with replacing line breaks in the data with spaces.
      >>
      >> here is my line:
      >>
      >> trim(stripslash es(str_replace( "\n", ' ',
      >> (htmlentities($ _POST["facexp"]))))));
      >>
      >> I end up with lots of   but the linebreaks are still there.
      >>
      >> What am I doing wrong?[/color]
      >
      > IIRC line breaks from an html textarea are supposed to be done with
      > \r\n so you'd want to str_replace("\r \n\", '&nbsp', ...[/color]

      Thank you.


      Comment

      Working...