Pongo el array antes y después, con algunas propiedades quitadas para resumir, y también algunas opciones, así que faltan índices:
Código:
Array
(
[0] => stdClass Object
(
[id_opcion] => 1
[nombre_es] => Empresa
[url] =>
[id_padre] => 0
[orden] => 1
[activo] => 1
[submenu] => Array
(
[0] => stdClass Object
(
[id_opcion] => 6
[nombre_es] => Sobre nosotros
[url] =>
[id_padre] => 1
[orden] => 1
[activo] => 1
[submenu] =>
)
[1] => stdClass Object
(
[id_opcion] => 7
[nombre_es] => Historia
[url] => #
[id_padre] => 1
[orden] => 2
[activo] => 1
[submenu] =>
)
)
)
[1] => stdClass Object
(
[id_opcion] => 2
[nombre_es] => Productos
[url] =>
[id_padre] => 0
[orden] => 1
[activo] => 1
[submenu] => Array
(
[1] => stdClass Object
(
[id_opcion] => 14
[nombre_es] => Colecciones
[url] =>
[id_padre] => 2
[orden] => 2
[activo] => 1
[submenu] => Array
(
[0] => stdClass Object
(
[id_opcion] => 15
[nombre_es] => Colección 1
[url] => #
[id_padre] => 14
[orden] => 1
[activo] => 1
[submenu] =>
)
[1] => stdClass Object
(
[id_opcion] => 16
[nombre_es] => Colección 2
[url] => #
[id_padre] => 14
[orden] => 2
[activo] => 1
[submenu] =>
)
)
)
[2] => stdClass Object
(
[id_opcion] => 24
[nombre_es] => Accesorios
[url] =>
[id_padre] => 2
[orden] => 3
[activo] => 1
[submenu] => Array
(
[0] => stdClass Object
(
[id_opcion] => 22
[nombre_es] => Colección 1
[url] => #
[id_padre] => 24
[orden] => 1
[activo] => 1
[submenu] =>
)
)
)
)
)
[2] => stdClass Object
(
[id_opcion] => 3
[nombre_es] => I+D
[url] =>
[id_padre] => 0
[orden] => 1
[activo] => 1
[submenu] => Array
(
[0] => stdClass Object
(
[id_opcion] => 11
[nombre_es] => Innovación
[url] => #
[id_padre] => 3
[orden] => 1
[activo] => 1
[submenu] =>
)
[1] => stdClass Object
(
[id_opcion] => 12
[nombre_es] => Ideas&Trends
[url] => #
[id_padre] => 3
[orden] => 2
[activo] => 1
[submenu] =>
)
)
)
[4] => stdClass Object
(
[id_opcion] => 5
[nombre_es] => Contacto
[url] =>
[id_padre] => 0
[orden] => 1
[activo] => 1
[submenu] =>
)
)
Código:
Array
(
[0] => stdClass Object
(
[id_opcion] => 1
[nombre_es] => Empresa
[url] =>
[id_padre] => 0
[orden] => 1
[activo] => 1
[submenu] =>
[nivel] => 0
)
[1] => stdClass Object
(
[id_opcion] => 6
[nombre_es] => Sobre nosotros
[url] =>
[id_padre] => 1
[orden] => 1
[activo] => 1
[submenu] =>
[nivel] => 0
)
[2] => stdClass Object
(
[id_opcion] => 7
[nombre_es] => Historia
[url] => #
[id_padre] => 1
[orden] => 2
[activo] => 1
[submenu] =>
[nivel] => 0
)
[6] => stdClass Object
(
[id_opcion] => 2
[nombre_es] => Productos
[url] =>
[id_padre] => 0
[orden] => 1
[activo] => 1
[submenu] =>
[nivel] => 1
)
[8] => stdClass Object
(
[id_opcion] => 14
[nombre_es] => Colecciones
[url] =>
[id_padre] => 2
[orden] => 2
[activo] => 1
[submenu] =>
[nivel] => 1
)
[9] => stdClass Object
(
[id_opcion] => 15
[nombre_es] => Colección 1
[url] => #
[id_padre] => 14
[orden] => 1
[activo] => 1
[submenu] =>
[nivel] => 1
)
[10] => stdClass Object
(
[id_opcion] => 16
[nombre_es] => Colección 2
[url] => #
[id_padre] => 14
[orden] => 2
[activo] => 1
[submenu] =>
[nivel] => 1
)
[18] => stdClass Object
(
[id_opcion] => 24
[nombre_es] => Accesorios
[url] =>
[id_padre] => 2
[orden] => 3
[activo] => 1
[submenu] =>
[nivel] => 2
)
[19] => stdClass Object
(
[id_opcion] => 22
[nombre_es] => Colección 1
[url] => #
[id_padre] => 24
[orden] => 1
[activo] => 1
[submenu] =>
[nivel] => 2
)
[20] => stdClass Object
(
[id_opcion] => 3
[nombre_es] => I+D
[url] =>
[id_padre] => 0
[orden] => 1
[activo] => 1
[submenu] =>
[nivel] => 2
)
[21] => stdClass Object
(
[id_opcion] => 11
[nombre_es] => Innovación
[url] => #
[id_padre] => 3
[orden] => 1
[activo] => 1
[submenu] =>
[nivel] => 2
)
[22] => stdClass Object
(
[id_opcion] => 12
[nombre_es] => Ideas&Trends
[url] => #
[id_padre] => 3
[orden] => 2
[activo] => 1
[submenu] =>
[nivel] => 2
)
[24] => stdClass Object
(
[id_opcion] => 5
[nombre_es] => Contacto
[url] =>
[id_padre] => 0
[orden] => 1
[activo] => 1
[submenu] =>
[nivel] => 3
)
)
Como se puede ver, los niveles de profundidad están mal asignados