Topic: Textbox, small unwanted ?new line? problem.

I am running a simple setup.  Anybody can write some text into a txt file, and then script will generate an image with the words. I use this as my signature on a discussion board. The script bases the height of the image depending on how many characters are in the txtfile.

The question: If somebody presses ?enter? in the text box, it makes a new line in the txtfile as well. How can i prevent newlines from even being put in? I tried str_replace("\n", "", $str); and a couple of different similar approaches/variations,  also truncating, stripping. What would be the best way to prevent  new lines ever being put in?

Its funny, when they database information is being displayed on the page of the script(not the image), all lines are ignored. :]

if you want to see the script to understand what i am talking about, its http://www.uniondead.com/index.php?id=shout

to see the generated image http://www.uniondead.com/signature/shout.php

Also, would it save a lot of CPU, to somehow save the image, to avoid generating it over every single time somebody loads the busy forum page?

Re: Textbox, small unwanted ?new line? problem.

Well, what I would do would be to use a regular text field instead of a multi-line textarea.

"Programming is like sex: one mistake and you have to support it for the rest of your life."

Re: Textbox, small unwanted ?new line? problem.

Aw.. no magical command to put everything in one line?
I guess i will just live with the bug. The textarea is a lot more appealing.

Re: Textbox, small unwanted ?new line? problem.

Well, the str_replace() above should do the trick. If it doesn't work, it can be related to the fact that linebreaks aren't always just a \n. They can sometimes be \r\n as well. Try this:

$str = str_replace("\n", "", str_replace("\r", "", $str));

"Programming is like sex: one mistake and you have to support it for the rest of your life."

Re: Textbox, small unwanted ?new line? problem.

Kennel, now i KNOW why you are doing such a great job on the forum.

Pure genius!

Thanks for help!