Io ho questo array, ma potete usarne uno qualsiasi
codice:
$array1['pp']['aa']='people/hearingloss.php';
$array1['pp']['aa']['h']='people/hearingloss/how.php';
$array1['pp']['aa']['c']='people/hearingloss/causes.php';
$array1['pp']['aa']['c']['z']='people/hearingloss/causes/conductive.php';
$array1['pp']['bb']='people/hearinginstruments.php';
$array1['pp']['bb']['p']='people/hearinginstruments/processing.php';
$array1['pp']['bb']['c']='people/hearinginstruments/choosing.php';
ho trovato questa funzione sul sito di php.net, pensavo facesse proprio al caso mio, visto che voglio scorrere tutta la struttura dell'array
codice:
$tree= "";
array_tree($your_array);
echo $tree;
// Recursive Function
function array_tree($array, $index=0){
global $tree;
$space="";
for ($i=0;$i<$index;$i++){
$space .= " ";
}
if(gettype($array)=="array"){
$index++;
while (list ($x, $tmp) = each ($array)){
$tree .= $space."$x => $tmp\n";
array_tree($tmp, $index);
}
}
}
Secondo quanto interpretato mi aspettavo stampasse tutta la struttura dell'array invece no, è possibile secondo voi che sia "sbagliata" oppure ho sbagliato io a interpretare?