EDIT: Sorry I didn't make this more clear. Replace "Echo" with "return" in front of "hi" and it returns null. I'm just showing that I can get inside that conditional.
This PHP function is supposed to calculate a sum of values passed from a database into an array. The function needs to be able to accept multiple columns (array) of values, and return an array of their summed values.
Below: $val is the column name and $result is the data returned from the query. So the data needs to be matched up with the correct keys (help by $val). As you can see I tried adding some checks to make sure the function is returning at the correct time. Echoing the variable shows that I am reaching that point, ("hi" is echoed) but it always returns NULL. Please feel free to ask questions if this is not clear enough.
function getSum($val,$result,$i=1,$count)
{
    $sum = array();
    if(is_array($val) == true)
    {
        foreach($val as $henh)
        {
            //echo $i;
            $this->getSum($henh,$result,$i,$count);
            $i++;
        }
    }
    else
    {
        $strs = explode('.',$val);
        $str = $this->getParameters(array($strs[1]));
        //var_dump($str[$strs[1]]); exit;
        if($str[$strs[1]]['Parameter']['type']=='int' || $str[$strs[1]]['Parameter']['type']=='float')
        {
            //echo $i;
            $c = true;
            foreach($result as $item)
            {
                foreach($item as $k=>$v)
                {
                    if($k==$val AND $v !== null)
                    {
                        $c = true;
                        $sum[$val][] =  intval($v);
                    }
                }
            }
            if($i==$count AND isset($sum[$val]) !== 0)
            {
                echo "hi!";
            }
        }
    }
}
 
     
     
     
     
    