如何使用PHP修剪字符串的最左边和最右边的空格?

What function can I use?

Use trim to remove whitespace at the start and end of a string.

left most

ltrim('text');

right most

rtrim('text');

but shortcut of above two is simply

trim('text');

string trim ( string $str [, string $charlist ] )

This function returns a string with whitespace stripped from the beginning and end of str

Checkout PHP Trim.