PHP removes trim () from the beginning and end of a string. the instance code is as follows: & lt ;? Php $ a & quot; (a, B, c,) & quot; echo $ a & quot; & lt; br & gt; & quot; output: (, b, c,) $ btrim ($ a, & quot; () & quot;); removes the first string
PHP removes the trim () function from the beginning and end of a string. the instance code is as follows:
-
- $ A = "(a, B, c ,)";
- Echo $ ."
"; // Output: (a, B, c ,)
- $ B = trim ($ a, "()"); // remove the character "(" or ")" contained at the beginning and end of the string.
- Echo $ B ."
"; // Output: a, B, c,
- $ C = trim ($ a, "(,)"); // remove the "(", "," or ")" characters at the beginning and end of the string.
- Echo $ c ."
"; // Output: a, B, c
- ?>
Output result:
(A, B, c ,)
A, B, c,
A, B, c
In SQL, trim () is used to remove spaces at the beginning and end, ltrim () is used to remove spaces on the left side of the string, and rtrim () is used to remove spaces on the right side of the string.