469,632 Members | 1,730 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,632 developers. It's quick & easy.

How to Remove Carriage return and line feeds.

Hi.

I have form that has a text box. I want insert unformatted text into the database.
Even if the user gives an carriage return or New line feed in the database it should be stored as on single line without any formatting.

I just want to remove
New Line Feed(\n)
Carriage Return(\r)
spaces at the begin and end of the string.

Eg:
If i have
text1(enter key pressed)
text2(enter key pressed)
text3(enter key pressed)
Blank space
Blank space

I want this to be stored in the DB as:
text1 text2 text3

Could someone help me with this?

Thanks
Apr 7 '08 #1
4 4427
ronverdonk
4,258 Expert 4TB
For removing characters you can use the str_replace() command.

We can help you when you start writing your own code. Then come back here when you run into problems or have questions. We do not supply ready made code.

Ronald
Apr 7 '08 #2
I already have the code ,Everything works fine but i want to store the data from a textarea without any formatting into the database.

Currrently it stores data with formatting like (\n)(\r)
i want to strip them off. and use one single line with spaces between words.

i used str_replace() but that does not seem to work.

Can someone helpme with this.

Thanks
Apr 7 '08 #3
aktar
105 100+
Try str_replace() with ascii codes
Apr 7 '08 #4
ronverdonk
4,258 Expert 4TB
Show your str_replace command here. I wonder if you defined the \n and \r within single quotes. When you did: that does not work. You have to include them within double quotes.

Show your str_replace() command anyway (within code tags)

Ronald
Apr 7 '08 #5

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

4 posts views Thread by McKirahan | last post: by
5 posts views Thread by McKirahan | last post: by
6 posts views Thread by Laura D | last post: by
2 posts views Thread by James | last post: by
reply views Thread by ajfish | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.