-7

I input string to textarea such as below:

         email1@gmail.com   
   email@gmail.com
 email3@gmail.com
      email4@gmail.com

How to format they to:

email1@gmail.com
email@gmail.com
email3@gmail.com
email4@gmail.com

One email in one line in textarea. I want use PHP to make it. Please help me about solution, thanks you.

3 Answers3

1

this should work in php str_replace(' ','',$yourText)

SmartCoder
  • 413
  • 2
  • 13
1

If you want to remove all whitespace:

$str = preg_replace('/\s+/', '', $yourstring);
Moby M
  • 910
  • 2
  • 7
  • 26
0

Use the trim function to do this.

return(trim($str));
Matias K.
  • 37
  • 10
  • This is the most elegant *looking*, but wouldn't you have to break it up by newline characters first, if it's all in one variable? – Cameron Hurd Nov 14 '17 at 13:12