我在第 5 行有这个警告,警告:为 foreach() 提供的参数无效
if (!function_exists('get_user_online_count')) {
function get_user_online_count($type=false,$full=true) {
global $counter_matrix;
$user_types=array();
foreach($counter_matrix as $key=>$val){
if(!isset($user_types[$val['user_type']])){
$user_types[$val['user_type']] = 0;
}
$user_types[$val['user_type']] ++;
}
if($full){
$print = '';
while(count($user_types)){
$user_type = key($user_types);
$user_count = array_shift($user_types);
if($type && $user_type != $type)continue;
if($print!=''){
if(count($user_types))$print .= ', ';
else $print .= ' and ';
}else{
}
$print .= $user_count . ' ' . $user_type . (($user_count>1)?'s':'');
}
if(!$print){
if($type){
$print = '0 '.$type.'s online';
}else{
$print = '0 Users online';
}
}else{
$print .= ' online';
}
return $print;
}else{
if($type){
return (isset($user_types[$type])) ? $user_types[$type] : 0;
}else{
return count($counter_matrix);
}
}
}
}
我在这一行有警告'foreach($counter_matrix as $key=>$val){'
这里怎么了???