Created
February 7, 2013 01:04
-
-
Save rubensanroman/4727476 to your computer and use it in GitHub Desktop.
Recorrer Array Multidimensional Recursivamente
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function recorro($matriz){ | |
foreach($matriz as $key=>$value){ | |
if (is_array($value)){ | |
//si es un array sigo recorriendo | |
echo 'key:'. $key; | |
echo '<br>'; | |
recorro($value); | |
}else{ | |
//si es un elemento lo muestro | |
echo $key.': '.$value ; | |
echo '<br>'; | |
} | |
} | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Esto no es recorrer un array recursivamente, por que estas usando un foreach. Recursivamente significaría que no uses bucles, sinó una función recursiva.