![]() | | ||||||||
| | #1 |
| www.whitedovebooks.co.uk War Room Member Join Date: Jan 2006 Location: United Kingdom.
Posts: 3,829
Blog Entries: 28 Thanks: 367
Thanked 718 Times in 294 Posts
|
Hi Guys I have a php script that takes input from a form and emails the results. Everything works fine, but users often use the [Return] key at the end of lines and I would like to strip those characters from the variable. What I usually get is something like this (2 paragraphs) ... The quick brown fox jumped over the lazy dog The quick brown fox jumped over the lazy dog The quick brown fox jumped over the lazy dog The quick brown fox jumped over the lazy dog The quick brown fox jumped over the lazy dog The quick brown fox jumped over the lazy dog But what I want is this (still 2 paragraphs, but with end-of line characters stripped and paragraphs still intact) ... The quick brown fox jumped over the lazy dog The quick brown fox jumped over the lazy dog The quick brown fox jumped over the lazy dog The quick brown fox jumped over the lazy dog The quick brown fox jumped over the lazy dog The quick brown fox jumped over the lazy dog Can anyone help? Many thanks Will |
| | |
| | |
| | #2 |
| Active Warrior War Room Member Join Date: May 2009 Location: Vancouver, British Columbia, Canada
Posts: 95
Thanks: 7
Thanked 8 Times in 7 Posts
|
Hi Will, The trim() function should work for this. Example: $text = "The quick brown fox jumped over the"; $emailThisOutput = trim($text, " \t."); \t represents a carriage return. Hope that helps. Craig |
| | |
| | |
| | #3 |
| Enthusiastic Warrior War Room Member |
Will, I've done this before in other programming languages. The outline is: 1. Search for all pairs of adjacent returns and replace them with an unusual code such as \|\. 2. Search for all returns and delete thems. 3. Search for the unique code and replace it with a pair of returns. Chris |
| | |
| | #4 |
| HyperActive Warrior War Room Member Join Date: May 2009 Location: U.K
Posts: 197
Thanks: 5
Thanked 39 Times in 36 Posts
| |
| Best Ways To Make Money Online Eight bytes walk into a bar. The bartender asks, “Can I get you anything?” “Yeah,” reply the bytes. “Make us a double.” | |
| | |
| | #6 |
| Enthusiastic Warrior War Room Member | |
| | |
![]() |
|
| Tags |
| characters, end, line, php, strip |
| Thread Tools | |
| |
![]() |