38.quotemeta(): 在字符串中某些预定义的字符前添加反斜线
$str = "Hello world. (can you hear me?)"; echo quotemeta($str); // Hello world. (can you hear me?)
39.chr(): 从指定的 ASCII 值返回字符
echo chr(052); // ASCII 值返回对应的字符
40.ord(): 返回字符串第一个字符的ASCII值
echo ord("hello"); 字符串第一个字符的 ASCII 值
字符串比较:
41.strcasecmp(): 不区分大小写比较两字符串
echo strcasecmp("Hello world!","HELLO WORLD!");
输入: 两个目标字符串 输出: 大1|等0|小 -1
42.strcmp(): 区分大小写比较两字符串
43.strncmp(): 比较字符串前n个字符,区分大小写
调用: int strncmp ( string $str1 , string $str2 , int $len)
44.strncasecmp(): 比较字符串前n个字符,不区分大小写
调用: int strncasecmp ( string $str1 , string $str2 , int $len )
45.strnatcmp(): 自然顺序法比较字符串长度,区分大小写
调用: int strnatcmp ( string $str1 , string $str2 )
输入: 目标字符串
46.strnatcasecmp(): 自然顺序法比较字符串长度, 不区分大小写
调用: int strnatcasecmp ( string $str1 , string $str2 )
字符串切割与拼接:
47.chunk_split():将字符串分成小块
调用: str chunk_split(str $body[,int $len[,str $end]])
输入: $body目标字串, $len长度, $str插入结束符 输出: 分割后的字符串
48.strtok(): 切开字符串
调用: str strtok(str $str,str $token)
目标字符串$str,以$token为标志切割返回切割后的字符串
49.explode(): 使用一个字符串为标志分割另一个字符串
调用: array explode(str $sep,str $str[,int $limit])
输入: $sep为分割符,$str目标字符串,$limit返回数组最多包含元素数 输出: 字符串被分割后形成的数组
50.implode(): 同join,将数组值用预订字符连接成字符串
调用: string implode ( string $glue , array $pieces )
$glue默认, 用''则直接相连
51.substr(): 截取字符串
调用: string substr ( string $string , int $start [, int $length ] )
字符串查找替换:
52.str_replace(): 字符串替换操作,区分大小写
调用mix str_replace(mix $search,mix $replace, mix $subject[,int &$num])
输入: $search查找的字符串,$replace替换的字符串,$subject被查找字串, &$num 输出: 返回替换后的结果
53.str_ireplace() 字符串替换操作,不区分大小写
调用: mix str_ireplace ( mix $search , mix $replace , mix $subject [, int &$count ] )
输入: $search查找的字符串,$replace替换的字符串,$subject被查找字串,&$num 输出: 返回替换后的结果
54.substr_count(): 统计一个字符串,在另一个字符串中出现次数
调用: int substr_count ( string $haystack , string $needle[, int $offset = 0 [, int $length ]] )







