Let me take a look at an implementation of removing specific characters or spaces at the beginning and end of a string in PHP and SQL. Here we only need to use trim.
PHP function trim() to remove specific characters at the beginning and end of a string
$a="(a,b,c,)";
echo $a."
"; //Output: (a,b,c,)
$b=trim($a,"()"); //Remove the characters "(" or ")" contained at the beginning and end of the string
echo $b."
"; //Output: a,b,c,
$c=trim($a,"(,)"); //Remove the characters "(", "," or ")" contained 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, the function trim() is used to remove leading and trailing spaces, ltrim() is to remove spaces on the left side of a string, and rtrim() is used to remove spaces on the right side of a string.
http://www.bkjia.com/PHPjc/632621.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/632621.htmlTechArticleLet me take a look at the implementation of PHP and SQL to remove specific characters or spaces at the beginning and end of a string. Here we only need Just use trim. PHP function tr to remove specific characters from the beginning and end of a string...