永利官网ylg客户端:PHP字符过滤函数去除字符串最终叁个逗号(rtrim卡塔尔

1.字符串的整理:chop(),itrim(),trim()trim()函数用来整理用户输入数据,如下显示:$name=trim($name);$email=trim($email);tirm()函数可以去除字符串开始位置和结束位置的空格,并将结果字符串返回。默认情况下去除换行符回车符(r)水平(t)和垂直制表符(x0B)
字符串结束符号()和空格。以下是来自于手册Without the second parameter,
rtrim() will strip these 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. * (ASCII 0
(0x00)), the NUL-byte. * x0B (ASCII 11 (0x0B)), a vertical
tabExample#1 Usage example of rtrim()?php$text = ttThese are a few
words 🙂 … ;$binary = x09Example stringx0A;$hello = Hello
World;var_dump($text, $binary, $hello);print n;$trimmed =
rtrim($text);var_dump($trimmed);$trimmed = rtrim($text,
t.);var_dump($trimmed);$trimmed = rtrim($hello,
Hdle);var_dump($trimmed);// trim the ASCII control characters at the
end of $binary// (from 0 to 31 inclusive)$clean = rtrim($binary,
x00..x1F);var_dump($clean);?上例将输出:string(32) These are a few
words 🙂 … string(16) Example stringstring(11) Hello Worldstring(30)
These are a few words 🙂 …string(26) These are a few words :)string(9)
Hello Worstring(15) Example string函数explode() implode() join()explode
使用一个字符串分割另一个字符串字符串的排序 strcmp() strcasecmp()
strnatcmp()在字符串中查找字符串 strstr() strchr() strrchr()
stristr()太多了,慢慢看手册<

string trim ( string $str [, string $charlist = ” tnrx0B” ]
)
此函数返回字符串 str 去除首尾空白字符后的结果。如果不指定第二个参数,
trim() 将去除这些字符:
1.” ” (ASCII 32 ,普通空格符。

过滤字符串中键的咚咚就只能用str_replace咯.
举个例子说明下,

以上函数功能,同时适用于ltrim,这2个函数
1、ltrim();删除字符串开头的空白字符
2、rtrim();删除字符串末端的空白字符

rtrim实例代码2 复制代码 代码如下:
$text = “ttThese are a few words 🙂 …  “;
$trimmed = rtrim($text);
// $trimmed = “ttThese are a few words 🙂 …”
$trimmed = rtrim($text, ” t.”);
// $trimmed = “ttThese are a few words :)”
$clean = rtrim($binary, “x00..x1F”);
// trim the ASCII control characters at the end of $binary
// (from 0 to 31 inclusive)
?>

发表评论

电子邮件地址不会被公开。 必填项已用*标注