码
$array = array($cat2);
print_r(array_count_values($array));
//out
Array ( [YES] => 1 ) Array ( [YES] => 1 ) Array ( [YES] => 1 ) Array ( [YES] => 1 ) Array ( [NO] => 1 ) Array ( [NO] => 1 ) Array ( [YES] => 1 ) Array ( [NO] => 1 ) Array ( [NO] => 1 ) Array ( [YES] => 1 )
多少计数是和否 这是我的代码
$YES = array_search('YES', $array);
$NO = array_search('NO', $array);
结果是YES
Array ( [YES] => 1 ) 0 Array ( [YES] => 1 ) 0 Array ( [YES] => 1 ) 0 Array ( [YES] => 1 ) 0 Array ( [NO] => 1 ) Array ( [NO] => 1 ) Array ( [YES] => 1 ) 0 Array ( [NO] => 1 ) Array ( [NO] => 1 ) Array ( [YES] => 1 ) 0
结果没有
Array ( [YES] => 1 )Array ( [YES] => 1 )Array ( [YES] => 1 )Array ( [YES] => 1 )Array ( [NO] => 1 )Array ( [NO] => 1 )Array ( [YES] => 1 )Array ( [NO] => 1 )Array ( [NO] => 1 )Array ( [YES] => 1 )
我有结果
YES = 6
NO = 4
这个没有mysql的php,请帮帮我......
答案 0 :(得分:0)
由于$array
是一个包含另一个数组的数组(我假设你想要分组),所以试试这个:
print_r(array_count_values($array[0]));