代码
$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);
结果是
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,请帮帮我......