Warning: Invalid argument supplied for foreach() php
<p>I have this warning at line 5 , Warning: Invalid argument supplied for foreach()</p>

<pre><code>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=&gt;$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 &amp;&amp; $user_type != $type)continue;
                if($print!=''){
                    if(count($user_types))$print .= ', ';
                    else $print .= ' and ';
                }else{

                }
                $print .= $user_count . ' ' . $user_type . (($user_count&gt;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);
            }
        }
    }
}
</code></pre>

<p>i have warning at this line 'foreach($counter_matrix as $key=>$val){'</p>

<p>Whats the wrong here ???</p>
