I have a few areas in an application of mine that I have <textarea> tags so users can enter messages to one another. A problem with some messages had been plaguing me for a while, but I could never figure out what the problem was. I would open up all the messages at once and save them in hidden tags. When the user 'opened' the message, the data from the tag would be gathered and shown in a lightbox for the user. For some reason, it wouldn't open some of those messages.
One of my users noticed that if you used a line-break (using 'shift+enter') in the message, it would break the Javascript when it tried to retrieve the message. Since this is only a problem when trying to read the message, I should be able to replace it when the message is sent in the first place.
How can I detect a line-break and replace it when it is submitted?
str_replace(???,"/n",$string)