Php 递归函数结果为数组,未显示所需结果

Php 递归函数结果为数组,未显示所需结果,php,ajax,arrays,recursion,codeigniter-2,Php,Ajax,Arrays,Recursion,Codeigniter 2,我有一个控制器ajax,其中有两个功能: function customer_comission() { --------------------------- --------------------------- $arr = $this->show_parent_id( $child_node ); var_dump($arr); --------------------

我有一个控制器
ajax
,其中有两个功能:

  function customer_comission()
  {
            ---------------------------
            ---------------------------
        $arr = $this->show_parent_id( $child_node );

        var_dump($arr);
            ----------------------------
            ---------------
  }

function show_parent_id( $cust_id ){

    if( $cust_id > 2 ):
        $cust_id2 = $this->comission_model->show_parent_id( $cust_id );
        $cust_array[] = $cust_id2;
        //echo $this->show_parent_id( $cust_id2 ); 
         $this->show_parent_id( $cust_id2 );  
    endif;

    return $cust_array; // <-- This is Line 38
}
功能客户委员会()
{
---------------------------
---------------------------
$arr=$this->show\u parent\u id($child\u node);
var_转储($arr);
----------------------------
---------------
}
函数show\u parent\u id($cust\u id){
如果($cust_id>2):
$cust\u id 2=$this->commission\u model->show\u parent\u id($cust\u id);
$cust_数组[]=$cust_id2;
//echo$this->show\u parent\u id($cust\u id2);
$this->show\u parent\u id($cust\u id2);
endif;

返回$cust_数组;//,这是因为无论何时
$cust_id 2){
$cust\u id 2=$this->commission\u model->show\u parent\u id($cust\u id);
$cust_数组[]=$cust_id2;
//echo$this->show\u parent\u id($cust\u id2);
$this->show\u parent\u id($cust\u id2);
}

返回$cust\u数组;//显然,当
$cust\u id委员会模型->显示家长id($cust\u id)
时,
$this->显示家长id($cust\u id)
就足够了吗?
$this->委员会模型->显示家长id($cust\u id)
从数据库返回
父id
。我指的是
委员会模型->
部分可能是多余的?它返回
传递的
$cust\u id的
父id
。结果的
父id
不在数组中
function show_parent_id( $cust_id ){
    $cust_array = array();
    if( $cust_id > 2 ){
        $cust_id2 = $this->comission_model->show_parent_id( $cust_id );
        $cust_array[] = $cust_id2;
        //echo $this->show_parent_id( $cust_id2 ); 
         $this->show_parent_id( $cust_id2 );  
    }

    return $cust_array; // <-- This is Line 38
}