php count_chars函数返回一个字符串,包含所有在字符串中使用过的不同字符,其语法是count_chars(string,mode),参数string必需,是规定要检查的字符串。 
php count_chars函数怎么用? 作用:返回一个字符串,包含所有在字符串中使用过的不同字符。 语法: count_chars(string,mode) 参数: string 必需。规定要检查的字符串。 mode 可选。规定返回模式。默认是 0。 以下是不同的返回模式: 0 - 数组,ASCII 值为键名,出现的次数为键值, 1 - 数组,ASCII 值为键名,出现的次数为键值,只列出出现次数大于 0 的值, 2 - 数组,ASCII 值为键名,出现的次数为键值,只列出出现次数等于 0 的值, 3 - 字符串,带有所有使用过的不同的字符, 4 - 字符串,带有所有未使用过的不同的字符。 说明:返回字符串中所用字符的信息 php count_chars()函数使用示例1 <?php
//使用模式3输出
$str = "Hello php.cn!";
echo count_chars($str,3);
?> 输出: !.Hcehlnop php count_chars()函数使用示例2 <?php
//使用模式1的数组形式输出
$str = "Hello php.cn!";
print_r(count_chars($str,1)) ;
?> 输出: Array ( [32] => 1 [33] => 1 [46] => 1 [72] => 1 [99] => 1 [101] => 1 [104] => 1 [108] => 2 [110] => 1 [111] => 1 [112] => 2 ) 以上就是php count_chars函数怎么用的详细内容,更多请关注模板之家(www.mb5.com.cn)其它相关文章! |