我想在 Codeigniter 中使用递归创建一个数组。我make_tree()
在控制器中的功能是:
function make_tree($customer_id,$arr = array()){
$ctree = $this->customer_operations->view_customer_tree($customer_id);
foreach($ctree as $v):
echo $customer_id = $v['customer_id'];
array_push($arr, $customer_id);
$this->make_tree($customer_id);
endforeach;
var_dump($arr);
}
但var_dump($arr)
结果echo
输出如下:
1013
array
empty
array
0 => string '13' (length=2)
11
array
empty
array
0 => string '10' (length=2)
1 => string '11' (length=2)
如何制作所有三个输出的单个数组,即包含元素的数组13,10,11