PHP 对字符串的常规操作

1 多个字符串操作
1-1 字符串比较
1 strcmp() 比较字符串
2 strcasecmp() 忽略大小写比较字符串
3 strncmp() 比较长度字符串
4 strncasecmp() 忽略大小写比较长度字符串
5 strnatcmp() 自然排序比较字符串
6 strnatcasecmp() 忽略大小写自然排序比较字符串
1-2 字符串分割
1 explode() 字符串拆分为数组
2 implode() 数组合并为字符串
3 split() 字符串按正则表达式拆分为字符串数组
4 str_split() 字符串拆分为相同长度字符串数组
5 chunk_split() 字符串按块拆分分为字符串数组
6 strtok() 字符串按特定分隔符拆分为字符串数组
7 parse_str() 字符串按url分割规律拆分为字符串数组
8 str_getcsv() 字符串按cvs字段个数拆分为字符串数组
9 nl2br() 字符串每换行中添加br
10 wordwrap() 字符串拆分并添加打断字符串
1-3 字符串相似度
1 levenshtein() 两个字符串的编辑距离
2 similar_text() 两个字符串的相似度
3 sundex()
4 metaphone()
1-4 字符串本地化
1 setlocale() 设置本地字符信息
2 localeconv() 返回本地字符信息
3 nl_langinfo() 返回本地字符信息
2 字符串整体操作
2-1 大小写转换操作
1 strtolower() 转换为小写
2 strtoupper() 转换为大写
3 lcfirst() 字符串首字母小写
4 ucfirst() 字符串首字母大写
5 ucwords() 字符串单词首字母大写
2-2 反斜线转换操作
1 addcslashes() 使用c风格反斜线转义字符串
2 addslashes() 使用反斜线转义字符串
3 stripslashes() 反引用c风格反斜线转义字符串
4 quotemeta() 转义元字符集
2-3 html字符转换操作
1 html_entity_decode() html实体转换为字符
2 htmlentities() 字符转换为html实体
3 htmlspecialchars_decode() html实体转换为特殊字符
4 htmlspecialchars() 特殊字符转换为html实体
5 get_html_translation_table() 获取html转换表格
6 strip_tags() 清除html和php标签
2-4 字符串编码转换操作
1 bin2hex() 字符串二进制编码转十六进制
2 hex2bin() 字符串十六进制编码转二进制
3 convert_uudecode() uuencode解码
4 convert_uuencode() uuencode解码
5 quoted_printable_decode() 8-bit解码
6 quoted_printable_encode() 8-bit编码
7 hebrev() 希伯来视觉编码
8 hebrevc() 希伯来逻辑编码
9 crc32()
10 crypt()
11 convert_cyr_string()
12 str_rot13()
2-5 字符串空格操作
1 ltrim() 删除字符串左侧空白
2 rtrim() 删除字符串右侧空白
3 trim() 删除字符串首尾空白
4 chop() rtrim别名
3 字符串内容操作
3-1 字符串顺序操作
1 strrev() 反转字符串
2 str_shuffle() 打乱字符串
3-2 字符串次数统计
1 count_chars() 字符串字符统计
2 chr() 获取ascii码对应字符
3 ord() 获取字符对应ascii码
4 str_word_count() 返回字符串中单词次数
5 substr_count() 返回子字符串的次数
3-3 字符串位置操作
1 strpos() 字符串中子字符串首次出现位置
2 strrpos() 字符串中子字符串最后出现位置
3 strripos() 忽略大小写字符串中子字符串最后出现位置
3-4 字符串部分操作
1 strstr() 返回目标字符串首次出现位置到整个字符串结尾的字符串
2 stristr() strstr()忽略大小写版本
3 strchr() 与strstr()相同
4 strrchr() 返回目标字符串最后出现位置到整个字符串结尾的字符串
3-5 substr() 返回指定位置长度子字符串
3-6 substr_replace() 替换指定位置长度字符串
3-7 substr_count() 返回指定子字符串中字符串出现次数
3-8 substr_compare() 比较字符串的一部分
3-9 str_replace() 字符串或字符串数组替换
3-10 str_ireplace() 忽略大小写的str_replace()
3-11 str_repeat()
3-12 str_pad()
4 字符串格式化与输入输出
4-1 money_format() 钱币格式化
4-2 number_format() 数字格式化
4-3 sscanf() 格式化输入
4-4 sprintf() 格式化输出
4-5 fscanf() 文件格式化输入
4-6 fprintf() 格式化输出到流
4-7 printf() 产生格式化输出
4-8 vsprintf() 格式化输出
4-9 vfprintf() 格式化输出到流
4-10 vprintf() 产生格式化输出
4-11 echo() 输出函数
4-12 print 输出结构体

猜你喜欢

转载自blog.csdn.net/hailanzi/article/details/80078792