I am 3 days trying to solve a problem, I can not get multiple arrays with 1 single index and put and a single array.
EX:
Está imprimindo assim:
Array(
[0]=> "MT"
)
Array(
[0]=> "MG"
)
Array(
[0]=> "AM"
)
Quero fazer assim:
Array([0]=>"MT", [1]=>"MT", [2]=>"MT")
//MEU BANCO DE DADOS CONSIDERANDO APENAS AS PESSOAS DA REDE DO ID 1001
id_usuario | uf
-------------------------
1001 | SP
1003 | MG
1005 | AM
1027 | MT
// MONTAGEM DA REDE
1001
/ \
1003 1005
/
1027
My code:
<?php
function buscarEstados1($id){
include 'includes/conexao.php';
$s_down = "select id from tab_afiliado where upline = $id";
$res_down = $cnns->query($s_down);
foreach ($res_down as $down){
$aff_uf = $down['id'];//var_dump($aff_uf); //PEGA OS IDS 1003, 1027, 1005
$s_uf = "select uf,id_endereco from tab_endereco WHERE id_endereco = " . $aff_uf . "";
$res_uf = $cnns->query($s_uf);
foreach ($res_uf as $uf){
$arr = $uf['uf']; //var_dump($arr); //PEGA AS UF MG , AM , MT
}
buscarEstados1($aff_uf);
}
}
buscarEstados1(1001);
?>
I would like to take the UF and make an array only Array ( "MG" , "AM" , "MT");
The problem is as if the loop caught like this.
print_r(#arr);
$arr = array( "MG" );
$arr = array( "MT" );
$arr = array( "AM" );