0

say I have a string like so

 Testing       

How could I have it remove all spaces before the first letter, and all spaces after the last letter in the string.

Thanks!

Charles
  • 50,943
  • 13
  • 104
  • 142
Belgin Fish
  • 19,187
  • 41
  • 102
  • 131
  • Duplicate of http://stackoverflow.com/questions/1892763/how-to-trim-leftmost-and-rightmost-whitespaces-of-a-string-using-php – Mark Byers Apr 07 '10 at 20:41

4 Answers4

2

Look here for all string functions in PHP.

http://php.net/manual/en/ref.strings.php

use trim(string)

Aaron
  • 7,431
  • 12
  • 35
  • 37
1

use trim()

Be sure to have this close by: String functions in PHP

Pekka
  • 442,112
  • 142
  • 972
  • 1,088
0

Try the trim function.

Ben Torell
  • 2,053
  • 1
  • 12
  • 15
0
string trim  (  string $str  [,  string $charlist  ] )
MJB
  • 7,639
  • 2
  • 31
  • 41