Ver Mensaje Individual
  #1 (permalink)  
Antiguo 06/02/2012, 18:35
climax2006
 
Fecha de Ingreso: abril-2006
Mensajes: 240
Antigüedad: 18 años, 8 meses
Puntos: 1
recorrer array multidimensional

hola
no se como recorrer un array de 3 dimensiones,
de antemanos gracias
Código PHP:
$niveles = array
        (
            array
                (
                    
"iditemcosto1" => 1,
                    
"descripcion" => "COSTO DE EJECUCION DE LAS OBRAS",
                    
"nivel2" => array
                        (
                            array
                                (
                                    
"iditemcosto1" => 1,
                                    
"iditemcosto2" => 1,
                                    
"descripcion" => "Tecnificación"
                                
),

                            array
                                (
                                    
"iditemcosto1" => 1,
                                    
"iditemcosto2" => 2,
                                    
"descripcion" => "Obras Civiles"
                                
),

                            array
                                (
                                    
"iditemcosto1" => 1,
                                    
"iditemcosto2" => 3,
                                    
"descripcion" => "Otros Costos"
                                
),

                            
"nivel3" => array
                                (
                                    array
                                        (
                                            
"iditemcosto1" => 1,
                                            
"iditemcosto2" => 3,
                                            
"iditemcosto3" => 18,
                                            
"descripcion" => "Letrero",
                                            
"montopesos" => 500000,
                                            
"montouf" => 22.3088001970313,
                                            
"mayusdescripcion" => "LETRERO"
                                        
),

                                    array
                                        (
                                            
"iditemcosto1" => 1,
                                            
"iditemcosto2" => 3,
                                            
"iditemcosto3" => 19,
                                            
"descripcion" => "Gastos Generales",
                                            
"montopesos" => 10000000,
                                            
"montouf" => 446.176003940626,
                                            
"mayusdescripcion" => "GASTOS GENERALES"
                                        
),

                                    array
                                        (
                                            
"iditemcosto1" => 1,
                                            
"iditemcosto2" => 3,
                                            
"iditemcosto3" => 20,
                                            
"descripcion" => "Imprevistos",
                                            
"montopesos" => 15000000,
                                            
"montouf" => 669.26400591094,
                                            
"mayusdescripcion" => "IMPREVISTOS"
                                        
)

                                )

                        )

                ),

            array
                (
                    
"iditemcosto1" => 3,
                    
"descripcion" => "COSTOS DE SUPERVISIÓN, ESTUDIOS Y PRESENTACIÓN",
                    
"nivel2" => array
                        (
                            array
                                (
                                    
"iditemcosto1" => 3,
                                    
"iditemcosto2" => 5,
                                    
"descripcion" => "Supervisión"
                                
),

                            array
                                (
                                    
"iditemcosto1" => 3,
                                    
"iditemcosto2" => 6,
                                    
"descripcion" => "Estudios"
                                
),

                            array
                                (
                                    
"iditemcosto1" => 3,
                                    
"iditemcosto2" => 7,
                                    
"descripcion" =>"Preparación y Presentación del Proyecto"
                                
),

                            
"nivel3" => array
                                (
                                    array
                                        (
                                            
"iditemcosto1" => 3,
                                            
"iditemcosto2" => 7,
                                            
"iditemcosto3" => 27,
                                            
"descripcion" => "Monto preparación y presentación del proyecto",
                                            
"montopesos" => 10000000,
                                            
"montouf" => 446.176003940626,
                                            
"mayusdescripcion" => "MONTO PREPARACIÓN Y PRESENTACIÓN DEL PROYECTO"
                                        
)

                                )

                        )

                )

        );

foreach (
$niveles as $rn) {
    echo 
$rn["descripcion"]."<br>";
    foreach (
$rn["nivel2"] as $rn2) {
        echo 
$rn2["descripcion"]."<br>";
        foreach (
$rn2["nivel2"]["nivel3"] as $rn3) {
            echo 
$rn3["descripcion"]."<br>";
        }
    }