$x = " abc ";
print(trim($x));
There are three versions of trim().
trim(): trims white space on both ends
rtrim(): trims white space on the right end
ltrim(): trims white space on the left end
Note that trim() does not remove white space in the middle of the string.