Les Tableaux PHP, ajoutant de la profondeur de l'élément de tableau de manière récursive sur un tableau avec les clés de la "profondeur"

Par l'exemple du tableau tout en bas, je veux être en mesure d'ajouter de la profondeur de chaque intégré tableau à l'intérieur de la matrice. par exemple:

 array ( 
53 => 
array ( 
'title' => 'à la Maison', 
'path' => ", 
'type' => '118', 
'pid' => 52, 
'hasChildren' => 0, 
), 

A une profondeur de un en fonction de l'échantillon tableau indiqué ci-dessous de sorte qu'il devrait maintenant ressembler à ceci:

 array ( 
53 => 
array ( 
'title' => 'à la Maison', 
'path' => ", 
'type' => '118', 
'pid' => 52, 
'hasChildren' => 0, 
la "profondeur" => 1, 
), 

et ainsi de suite...

Tous les récursif de la fonction de tableau de tentatives que j'ai faites sont vraiment gênant. Toutefois, j'ai regardé RecursiveArrayIterator qui a le getDepth fonction. Je suis confus sur la façon de les ajouter à la panoplie... toute aide est TRÈS apprécié, merci.

 
array ( 
'title' => "du Site', 
'path' => ", 
'type' => '115', 
'pid' => 0, 
'hasChildren' => 1, 
'les enfants' => 
array ( 
53 => 
array ( 
'title' => 'à la Maison', 
'path' => ", 
'type' => '118', 
'pid' => 52, 
'hasChildren' => 0, 
), 
54 => 
array ( 
'title' => 'Fonctions', 
'path' => 'fonctions', 
'type' => '374', 
'pid' => 52, 
'hasChildren' => 1, 
'les enfants' => 
array ( 
59 => 
array ( 
'title' => "artistique", 
'path' => 'features/artistique", 
'type' => '374', 
'pid' => 54, 
'hasChildren' => 1, 
'les enfants' => 
array ( 
63 => 
array ( 
'title' => 'galeries', 
'path' => 'features/artistique/galeries', 
'type' => '374', 
'pid' => 59, 
'hasChildren' => 1, 
'les enfants' => 
array ( 
65 => 
array ( 
'title' => 'graphique', 
'path' => 'features/artistique/galeries d'art/graphiques', 
'type' => '118', 
'pid' => 63, 
'hasChildren' => 0, 
), 
67 => 
array ( 
'title' => 'medium mixte', 
'path' => 'features/artistique/galeries/mixte-medium', 
'type' => '118', 
'pid' => 63, 
'hasChildren' => 0, 
), 
64 => 
array ( 
'title' => 'aperçu', 
'path' => 'features/artistique/galeries', 
'type' => '118', 
'pid' => 63, 
'hasChildren' => 0, 
), 
68 => 
array ( 
'title' => "photographie", 
'path' => 'features/artistique/galeries d'art/photographie", 
'type' => '118', 
'pid' => 63, 
'hasChildren' => 0, 
), 
66 => 
array ( 
'title' => 'traditionnels', 
'path' => 'features/artistique/galeries/traditionnel", 
'type' => '118', 
'pid' => 63, 
'hasChildren' => 0, 
), 
), 
), 
62 => 
array ( 
'title' => 'aperçu', 
'path' => 'features/artistique", 
'type' => '118', 
'pid' => 59, 
'hasChildren' => 0, 
), 
69 => 
array ( 
'title' => 'tutoriels', 
'path' => 'features/artistique/tutoriels', 
'type' => '374', 
'pid' => 59, 
'hasChildren' => 1, 
'les enfants' => 
array ( 
71 => 
array ( 
'title' => "par catégorie", 
'path' => 'features/artistique/tutoriels/par-categorie/', 
'type' => '118', 
'pid' => 69, 
'hasChildren' => 0, 
), 
72 => 
array ( 
'title' => 'par date', 
'path' => 'features/artistique/tutoriels/par-date/', 
'type' => '118', 
'pid' => 69, 
'hasChildren' => 0, 
), 
70 => 
array ( 
'title' => 'aperçu', 
'path' => 'features/artistique/tutoriels', 
'type' => '118', 
'pid' => 69, 
'hasChildren' => 0, 
), 
), 
), 
), 
), 
58 => 
array ( 
'title' => 'aperçu', 
'path' => 'fonctions', 
'type' => '118', 
'pid' => 54, 
'hasChildren' => 0, 
), 
61 => 
array ( 
'title' => 'projets /labs", 
'path' => 'features/projets-labs/', 
'type' => '374', 
'pid' => 54, 
'hasChildren' => 0, 
), 
60 => 
array ( 
'title' => 'web', 
'path' => 'features/web-développement", 
'type' => '374', 
'pid' => 54, 
'hasChildren' => 1, 
'les enfants' => 
array ( 
74 => 
array ( 
'title' => 'articles', 
'path' => 'features/développement web/articles/', 
'type' => '374', 
'pid' => 60, 
'hasChildren' => 0, 
), 
73 => 
array ( 
'title' => 'aperçu', 
'path' => 'features/web-développement", 
'type' => '118', 
'pid' => 60, 
'hasChildren' => 0, 
), 
75 => 
array ( 
'title' => 'tutoriels', 
'path' => 'features/développement web/tutoriels', 
'type' => '374', 
'pid' => 60, 
'hasChildren' => 0, 
), 
), 
), 
), 
), 
55 => 
array ( 
'title' => 'Activité', 
'path' => 'activité', 
'type' => '374', 
'pid' => 52, 
'hasChildren' => 0, 
), 
56 => 
array ( 
'title' => 'Blog', 
'path' => 'blog', 
'type' => '374', 
'pid' => 52, 
'hasChildren' => 0, 
), 
57 => 
array ( 
'title' => 'à Propos', 
'path' => 'à propos', 
'type' => '374', 
'pid' => 52, 
'hasChildren' => 1, 
'les enfants' => 
array ( 
76 => 
array ( 
'title' => 'l'auteur', 
'path' => "/la-auteur", 
'type' => '118', 
'pid' => 57, 
'hasChildren' => 0, 
), 
77 => 
array ( 
'title' => "le site", 
'path' => "/le-site web', 
'type' => '118', 
'pid' => 57, 
'hasChildren' => 0, 
), 
), 
), 
), 
), 
); 

print_r($exemple); 

?> 

OriginalL'auteur youdontmeanmuch | 2009-01-12