Skip to content

Instantly share code, notes, and snippets.

@rubensanroman
Created February 7, 2013 01:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rubensanroman/4727476 to your computer and use it in GitHub Desktop.
Save rubensanroman/4727476 to your computer and use it in GitHub Desktop.
Recorrer Array Multidimensional Recursivamente
<?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>';
}
}
}
?>
@sergioatanacio
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment