标签:class div params values 区别 turn color count http
PHP4,PHP5,PHP7
1.函数的作用:计算数组中元素出现的个数;
2.函数的参数:
@params array arrays
3.要点:
1)区别大小写;
2)数组中的元素如果不是字符串或者整数会报错;
3)空字符串是合法的;
4.例子:
$arr = [ ‘a‘, ‘b‘, ‘A‘, ]; print_r(array_count_values($arr)); $arr = [ ‘a‘, ‘b‘, ‘A‘, ]; print_r(array_count_values(array_map(‘strtolower‘,$arr)));
$arr1 = [‘a‘, ‘b‘, ‘A‘]; $arr2 = [‘a‘, ‘b‘, ‘A‘]; print_r(array_count_values(array_merge($arr1,$arr2))); print_r(array_count_values(array_map(‘strtolower‘,array_merge($arr1,$arr2))));
/*
* http://php.net/manual/en/function.array-count-values.php
*/
function assc_array_count_values( $array, $key ) { foreach( $array as $row ) { $new_array[] = $row[$key]; } return array_count_values($new_array); } // 查看合格率的情况 $arr = [ ‘20170417‘ => [‘QualificationA‘ => ‘98%‘, ‘QualificationB‘ => ‘80%‘, ‘QualificationC‘ => ‘60%‘], ‘20170418‘ => [‘QualificationA‘ => ‘95%‘, ‘QualificationB‘ => ‘90%‘, ‘QualificationC‘ => ‘40%‘], ]; print_r((assc_array_count_values($arr,‘QualificationC‘)));
标签:class div params values 区别 turn color count http
原文地址:http://www.cnblogs.com/jingjingdidunhe/p/6721186.html