soy nuevo en esto y estoy intentando hacer una funcion recursiva en php public function recursive_tree($valor) { $consulta = $this->Modelo->Getdata('getHijos', $valor); if ($consulta->num_rows() > 0) { foreach ($consulta->result() as $p) { $arbol[] = array("id_user" => $p->id_user, "nombre" => $p->nombre, "id_raiz" => $p->id_raiz); $this->recursive_tree($p->id_user); } echo json_encode($arbol); } }
public function recursive_tree($valor) {
$consulta = $this->Modelo->Getdata('getHijos', $valor);
if ($consulta->num_rows() > 0) {
foreach ($consulta->result() as $p) {
$arbol[] = array("id_user" => $p->id_user, "nombre" => $p->nombre, "id_raiz" => $p->id_raiz);
$this->recursive_tree($p->id_user);
}
echo json_encode($arbol);
}
}
, obtengo todos los datos que necesito pero la respuesta queda es`[{"id_user":"31","nombre":"lorena","id_raiz":"29"},{"id_user":"32","nombre":"pedro","id_raiz":"29"}]es
[{"id_user":"33","nombre":"juan","id_raiz":"30"},{"id_user":"34","nombre":"jose","id_raiz":"30"},]`,
[{"id_user":"31","nombre":"lorena","id_raiz":"29"},
{"id_user":"32","nombre":"pedro","id_raiz":"29"}]
[{"id_user":"33","nombre":"juan","id_raiz":"30"},
{"id_user":"34","nombre":"jose","id_raiz":"30"},],
como dos objetos distintos, lo que intento obtener es unir ambos.
[{"id_user":"31","nombre":"lorena","id_raiz":"29"},{"id_user":"32","nombre":"pedro","id_raiz":"29"}, {"id_user":"33","nombre":"juan","id_raiz":"30"},{"id_user":"34","nombre":"jose","id_raiz":"30"},]
espero
[{"id_user":"31","nombre":"lorena","id_raiz":"29"},{"id_user":"32","nombre":"pedro","id_raiz":"29"},
{"id_user":"33","nombre":"juan","id_raiz":"30"},{"id_user":"34","nombre":"jose","id_raiz":"30"},]
espero haberme expresado bien y gracias por su ayuda.