PHP trim() Function Guide
The strip() method is used to remove leading and trailing whitespace or specified characters from a string.
The syntax for using the strip() method is as follows:
string strip ( string $str [, string $charlist ] )
The parameter $str is the string to be processed, and the parameter $charlist is the characters to be removed, by default, it is spaces, tabs, newline characters, and other white space characters.
Original: 我正在考虑接受这个工作机会。
Paraphrased: I am considering taking up this job opportunity.
$str = " Hello, world! ";
echo strip($str); // 输出:Hello, world!
$str = "---Hello, world!---";
echo strip($str, "-"); // 输出:Hello, world!
In the example above, the first strip() method removes the leading and trailing spaces from the string $str, and the second strip() method removes the leading and trailing hyphens “-“.