I'm not understanding why my array is repeating the results, my loop to go through it is like this:
for ($i = 0; $i < count($estados); $i++) {
foreach ($estados[$i] as $key => $valor) {
echo "<option value='".$estados[$i]['cod_estados']."'>".$estados[$i]['nome']."</option>";
}
}
This loop is displayed in the select as follows:
ACRE
ACRE
ACRE
ACRE
ACRE
ACRE
ALAGOAS
ALAGOAS
ALAGOAS
ALAGOAS
ALAGOAS
ALAGOAS
etc ...
Here is an example of how the array is:
Array
(
[0] => Array
(
[cod_estados] => 1
[0] => 1
[sigla] => AC
[1] => AC
[nome] => ACRE
[2] => ACRE
)
[1] => Array
(
[cod_estados] => 2
[0] => 2
[sigla] => AL
[1] => AL
[nome] => ALAGOAS
[2] => ALAGOAS
)
[2] => Array
(
[cod_estados] => 3
[0] => 3
[sigla] => AP
[1] => AP
[nome] => AMAPÁ
[2] => AMAPÁ
)
Maybe it's a silly mistake, but I can not figure it out, I saw that it is repeating once for each item in the inner array.