ok, well first off i have a form text area and i have it subbmitted into php...now, i would like for all the line breaks to be gone, so that the whole thing can be in one line...

for example:

i put in:
i want
a dog
for my
birthday

and i want it to come out:
i want a dog for my birthday

can anybody help...

ive tried:

str_replace("\n", "", $string);

but it doesnt work...

help me 🙁

thanks...

    Have you try :

    $string = str_replace("\n", "", $string);

    ?

      I had an opposite problem because the text field input was all in line and I had to modify it not to be...

        try
        $string = str_replace("\n", "", $string);
        $string = str_replace("\r", "", $string);

          ive already tried the str_replace for \n, but whats \r?

            aw..shit...thanks so much man..it worked..

              Originally posted by STooPID
              ive already tried the str_replace for \n, but whats \r?

              Generally speaking a newline consists of a \n\r setup, the \n by itself means newline the \r could translate to "return to left" I suppose and together they would be considered a carriage return -- however \n alone often does the function of both

                Originally posted by tekky
                Generally speaking a newline consists of a \n\r setup, the \n by itself means newline the \r could translate to "return to left" I suppose and together they would be considered a carriage return -- however \n alone often does the function of both

                Not really.
                The newline character is represented by \n
                The newline sequence depends on the platform, and could be the newline character, the carriage return character (\r), or a carriage return and newline character pair (\r\n).
                I'm not sure where you got \n\r from.

                  Originally posted by laserlight

                  I'm not sure where you got \n\r from.

                  My apologies, its been a bad (read: extremely long) weak, I did mean \r\n

                  chalk that up as stupid mistake #2 for the night :eek:

                    Originally posted by STooPID
                    aw..****...thanks so much man..it worked..

                    Resolved? Mark it! 🙂

                      Write a Reply...