I have a good question, I was able to identify the problem, but I could not solve it .. hahahaha
It is the following ... I have the following array:
array:7 [▼
1 => array:5 [▶]
2 => array:5 [▶]
4 => array:5 [▶]
10 => array:5 [▶]
16 => array:5 [▶]
22 => array:5 [▶]
13 => array:1 [▶]
]
You may notice that my key in each array is not sequential, ie start at 0 and go to N. I am using to create the key the id of my records that are in the bank ... So far it's all right It's cute!
The problem is that when I use a FOREACH to go through the elements and display the values, as an example, "name" it returns me saying that INDEX does not exist ... however if I use an output vardump or print_r is displaying the values. I did a test running only once the foreach and it correctly displayed the NAME value the problem occurs after Key 2, I believe it is because it is not in the key order, however the problem is that the way I did I got access easier for the children of each Array ...To get a better view I'm putting down the complete Array:
Array
(
[1] => Array
(
[id] => 1
[name] => Inicio
[link] => #start
[icon] => fa fa-tachometer
[children] => Array
(
[0] => Array
(
[id] => 8
[name] => Dashboard Eventos
[link] => index/Dashboard-Vendas
[icon] => fa fa-caret-right
)
[1] => Array
(
[id] => 9
[name] => Dashboard Monitor
[link] => index/Dashboard-Monitor
[icon] => fa fa-caret-right
)
)
)
[2] => Array
(
[id] => 2
[name] => Cadastros
[link] => #clientes
[icon] => fa fa-user
[children] => Array
(
[0] => Array
(
[id] => 3
[name] => Clientes
[link] => clientes/Clientes
[icon] => fa fa-caret-right
)
)
)
[4] => Array
(
[id] => 4
[name] => Empresa
[link] => #empresas
[icon] => fa fa-building
[children] => Array
(
[0] => Array
(
[id] => 6
[name] => Usuarios
[link] => empresas/Colaborador
[icon] => fa fa-caret-right
)
[1] => Array
(
[id] => 11
[name] => Equipes
[link] => empresas/Equipes
[icon] => fa fa-caret-right
)
[2] => Array
(
[id] => 12
[name] => Minhas Empresas
[link] => empresas/Empresas
[icon] => fa fa-caret-right
)
[3] => Array
(
[id] => 20
[name] => Veiculos Valores
[link] => empresas/Veiculos-Valor
[icon] => fa fa-caret-right
)
[4] => Array
(
[id] => 25
[name] => Departamentos
[link] => empresas/Departamentos
[icon] => fa fa-caret-right
)
)
)
[10] => Array
(
[id] => 10
[name] => Oportunidades
[link] => #oportunidades
[icon] => fa fa-thumbs-up
[children] => Array
(
[0] => Array
(
[id] => 7
[name] => Relatorios
[link] => oportunidades/Oportunidades
[icon] => fa fa-caret-right
)
[1] => Array
(
[id] => 21
[name] => Carregar Eventos
[link] => oportunidades/Upload-Eventos
[icon] => fa fa-caret-right
)
)
)
[16] => Array
(
[id] => 16
[name] => Mesa de Credito
[link] => #credito
[icon] => fa fa-money
[children] => Array
(
[0] => Array
(
[id] => 17
[name] => Propostas
[link] => propostas/Propostas
[icon] => fa fa-caret-right
)
[1] => Array
(
[id] => 18
[name] => Relatorios
[link] => credito/Relatorios
[icon] => fa fa-caret-right
)
)
)
[22] => Array
(
[id] => 22
[name] => Pesquisa Satisfacao
[link] => #pesquisas
[icon] => fa fa-line-chart
[children] => Array
(
[0] => Array
(
[id] => 23
[name] => Pesquisas
[link] => pesquisas/Pesquisas
[icon] => fa fa-caret-right
)
[1] => Array
(
[id] => 24
[name] => Relatorios
[link] => pesquisas/Relatorios
[icon] => fa fa-caret-right
)
)
)
[13] => Array
(
[children] => Array
(
[0] => Array
(
[id] => 14
[name] => Minhas Campanhas
[link] => campanhas/Minhas-Campanhas
[icon] => fa fa-caret-right
)
[1] => Array
(
[id] => 15
[name] => Relatorios
[link] => campanhas/Relatorios
[icon] => fa fa-caret-right
)
)
)
)
I'm accessing the Array as follows:
<?php foreach($menu as $m): ?>
<a class="nav-item nav-link" data-toggle="tab" href="#nav-file"><?php $m['name']; ?></a>
<?php endforeach; ?>