如何从函数返回数组?

This function was okay for yesterday, I have no idea why it can't return array value now.

I tried to dump out the value at Xxxx...the result was perfect...but when I dump before return $downlinesArray(last return) I only get the first array[0] value...which is passing from another function...I have no idea why...can anyone point it out?

And after it returns the array, I get nothing from another side. Which is calling this function and get array value.

function findEntireGroupDownlinesMemberID($downlinesArray, $index)
{
    $downlineDB = $this->getDistributorInformation($downlinesArray[$index]);
    if ($downlineDB) {
Xxxx
        if ($downlineDB->getLeftPositionDistCode()) {
            array_push($downlinesArray, $downlineDB->getLeftPositionDistCode());
        }

        if ($downlineDB->getRightPositionDistCode()) {
            array_push($downlinesArray, $downlineDB->getRightPositionDistCode());
        }
        $index++;
        return $this->findEntireGroupDownlinesMemberID($downlinesArray, $index);
    }
    return $downlinesArray;
}

If you need to modify the original $downlinesArray array, you need to pass it to your function by its reference. Also you get an error because your code never reaches the second return statement. Check the snippet:

{
    if ($downlineDB) {  //if this is true, the 2nd return statement will never get executed.
    Xxxx
        if ($downlineDB->getLeftPositionDistCode()) {
            array_push($downlinesArray, $downlineDB->getLeftPositionDistCode());
        }

        if ($downlineDB->getRightPositionDistCode()) {
            array_push($downlinesArray, $downlineDB->getRightPositionDistCode());
        }
         $index++;
         return $this->findEntireGroupDownlinesMemberID($downlinesArray, $index);  //function exits here
    }
    return $downlinesArray;
}

And when $downlineDB evaluates to be false, all you get is the first array value array[0] as expected.