常用函数如下:(红色为重点)
1、取字符串的长度
echo strlen("hello");
2、echo strcmp(“字符串1","字符串2");
比较两个字符串是否相等,区分大小写 相同返回0
3、echo strcasecmp(“字符串1","字符串2");
比较两个字符串是否相等,不区分大小写相同返回0
4、转小写
echo strtolower("HELLO");
5、转大写
echo strtoupper("hello");
6、将字符串s拆分,返回数组
$s = "hello|world|test";
$arr = explode("|",$s);
7、将数组元素拼接成字符串
$arr = array("111","222","333");
echo implode(",",$arr);
8、截取替换
$s = "hello world";
echo substr_replace($s,"*",0,2);
9、查找替换
$s = "hello world";
echo str_replace("l","*",$s);
10、截取字符串
$s = "hello world";
echo substr($s,0,5);
结构图如下: