0
How to join arrays with a multidimensional array:
Array (
[0] => 1
[1] => 2
[2] => 3
[3] => 4
[4] => 5
[5] => Array ( [cod_setor] => 1 )
[6] => Array ( [cod_setor] => 2 )
[7] => Array ( [cod_setor] => 3 )
[8] => Array ( [cod_setor] => 5 )
)
See how this my code:
//$item_inventarios = valor recebido da controller codeigniter
$inicial = $listar_menor_maior_setor[0]['menor_cod_setor'];
$final = $listar_menor_maior_setor[0]['maior_cod_setor'];
$lista = range($inicial, $final);
$total = array_merge($lista,$item_inventarios);
print_r($total);
The expected result would be this:
Array (
[0] => Array ( [ambiente_setor] => 1 )
[1] => Array ( [ambiente_setor] => 2 )
[2] => Array ( [ambiente_setor] => 3 )
[3] => Array ( [ambiente_setor] => 4 )
[4] => Array ( [ambiente_setor] => 5 )
[5] => Array ( [cod_setor] => 1 )
[6] => Array ( [cod_setor] => 2 )
[7] => Array ( [cod_setor] => 3 )
[8] => Array ( [cod_setor] => 5 )
)
What kind of union would that be? What would be the expected result?
– Woss
The expected result would be this:
Array (
 [0] => Array ( [ambiente_setor] => 1 )
 [1] => Array ( [ambiente_setor] => 2 )
 [2] => Array ( [ambiente_setor] => 3 )
 [3] => Array ( [ambiente_setor] => 4 )
 [4] => Array ( [ambiente_setor] => 5 )
 [5] => Array ( [cod_setor] => 1 ) 
 [6] => Array ( [cod_setor] => 2 ) 
 [7] => Array ( [cod_setor] => 3 ) 
 [8] => Array ( [cod_setor] => 5 ) 
)
– Hugo Rutemberg