0
0
1.字符串的整理:chop(),itrim(),trim()
trim()函数用来整理用户输入数据,如下显示:
$name=trim($name);
$email=trim($email);
tirm()函数可以去除字符串开始位置和结束位置的空格,并将结果字符串返回。默认情况下去除换行符(n)回车符(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 tab
Example#1 Usage example of rtrim()
$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 string
"
string(11) "Hello World"
string(30) " These are a few words :) ..."
string(26) " These are a few words :)"
string(9) "Hello Wor"
string(15) " Example string"
函数explode() implode() join()
explode — 使用一个字符串分割另一个字符串
字符串的排序 strcmp() strcasecmp() strnatcmp()
在字符串中查找字符串 strstr() strchr() strrchr() stristr()
太多了,慢慢看手册
trim()函数用来整理用户输入数据,如下显示:
$name=trim($name);
$email=trim($email);
tirm()函数可以去除字符串开始位置和结束位置的空格,并将结果字符串返回。默认情况下去除换行符(n)回车符(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 tab
Example#1 Usage example of rtrim()
$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 string
"
string(11) "Hello World"
string(30) " These are a few words :) ..."
string(26) " These are a few words :)"
string(9) "Hello Wor"
string(15) " Example string"
函数explode() implode() join()
explode — 使用一个字符串分割另一个字符串
字符串的排序 strcmp() strcasecmp() strnatcmp()
在字符串中查找字符串 strstr() strchr() strrchr() stristr()
太多了,慢慢看手册
本站声明:本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
热门AI工具
相关专题
2026赚钱平台入口大全
2026年最新赚钱平台入口汇总,涵盖任务众包、内容创作、电商运营、技能变现等多类正规渠道,助你轻松开启副业增收之路。阅读专题下面的文章了解更多详细内容。
76
2026.01.31
无需付费的漫画app大全
想找真正免费又无套路的漫画App?本合集精选多款永久免费、资源丰富、无广告干扰的优质漫画应用,涵盖国漫、日漫、韩漫及经典老番,满足各类阅读需求。阅读专题下面的文章了解更多详细内容。
67
2026.01.31
漫画免费在线观看地址大全
想找免费又资源丰富的漫画网站?本合集精选2025-2026年热门平台,涵盖国漫、日漫、韩漫等多类型作品,支持高清流畅阅读与离线缓存。阅读专题下面的文章了解更多详细内容。
19
2026.01.31
热门下载
精品课程







