2019-06-06 01:08
浏览 62


I am in the process of updating my CodeIgniter app from version 2.x to 3.1. Previously, I used to call this function to count the number of non-zero numbers in the passed-in array:

function getCountOfNonZero($array, $d) {
    $NonZeroCount = 0;
    foreach($array as $key=>$value) {
        if(is_array($value)) {
            $d = $key;
            $NonZeroCount += getCountOfNonZero($value, $d); }
        else {
              if($value<>0 & $key<>'RES') {
    return $NonZeroCount;

Now that I am trying to call this function in version 3.1 of CodeIgniter, I am getting an error. This is how I call the function:

echo "Count of non-zero is: ".$controller->getCountOfNonZero($myArray);

One thing that is different is that the function is in system\core\Controller.php but this is returning an error whenever I call the function and try to pass in the array.

Is there any reason why I can't pass an array to the core system controller in CodeIgniter?

1条回答 默认 最新

相关推荐 更多相似问题