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,010
  • 13
  • 100
  • 141
Belgin Fish
  • 17,849
  • 40
  • 101
  • 129
  • 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,291
  • 12
  • 34
  • 37
1

use trim()

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

Pekka
  • 431,103
  • 135
  • 960
  • 1,075
0

Try the trim function.

Ben Torell
  • 2,023
  • 1
  • 12
  • 15
0
string trim  (  string $str  [,  string $charlist  ] )
MJB
  • 7,559
  • 2
  • 30
  • 41