作为黄金搭档,PHP和MySQL都有自己的删除空白函数,而且函数名字也一样:trim(), ltrim(), rtrim()。当然,作为编程语言,PHP删除空白函数更为强大。
对 ltrim()和rtrim(),从其英语解释来看:
以下是引用片段:
PHP为:Strip whitespace (or other characters)
MySQL为:space characters removed
显然,PHP还可以有“other characters”,而且PHP的函数还可以用第二个参数自定义要删除的字符。
对“other characters”,手册解释为:
以下是引用片段:
代码如下复制代码 ” ” (ASCII 32 (0x20)), an ordinary space.
“t” (ASCII 9 (0x09)), a tab.
“n” (ASCII 10 (0x0A)), a new line (line feed).
“r” (ASCII 13 (0x0D)), a carriage return.
“