crazygogo
Messages postés
135
Date d'inscription
samedi 18 janvier 2003
Statut
Membre
Dernière intervention
17 avril 2009
3 avril 2008 à 18:58
Bon je sais que c'est pas du bon code, optimisé, bien codé et tout et tout mais c'est un bricolage que j'essaie de faire pour créer mon tableau !!! alors pour vous montrer ou j'en suis, je met ci-dessous mon code, puis les informations de debugage qu'il affiche...
tout en bas de ces infos de debug : tree2 = le tableau que je parviens à générer : il est pas mal mais un seul niveau d'arbo seulement alors que le deuxieme niveau devrait être affecté d'après les infos de debug par la fonction rempliBranche (la même qui me rempli bien mon premier niveau !!)
la j'avoue que je suis un peu pommé !!!....
CODE :
// On récupère tous les dossier et sous-dossiers de l'utilisateur :
$tree1 = array();
$sql = 'SELECT *
FROM gestion_documentaire_dossiers
ORDER BY dossier_nom;';
$DB_CX->DbQuery($sql);
while ($enr = $DB_CX->DbNextRow()) {
$dossier_parent_id = $enr['dossier_parent_id'];
if(trim($dossier_parent_id=='')){
$dossier_parent_id = 0;
}
$tree1[] =
array(
'dossier_id' => $enr['dossier_id'],
'dossier_parent_id' => $dossier_parent_id,
'dossier_nom' => $enr['dossier_nom']
);
}
$cpt = 0;
$tree2 = array();
$dossiersDejaCrees = array();
foreach ($tree1 as $id => $dossier) {
if($dossier['dossier_parent_id']==0){
$dossiersDejaCrees[] = $dossier['dossier_id'];
$tree2[$cpt] = $dossier;
unset($tree1[$id]);
$tree2[$cpt]['dossier_fils'] = array();
$cpt ++;
}
}
echo('<hr><hr><hr>tree1 : ');
print_r($tree1);
echo('
');
echo('<hr><hr><hr>tree2 : ');
print_r($tree2);
echo('
<hr><hr><hr>');
// Tant que le tree1 est pas vide (on efface ses entrées au fur et a mesure qu'on les insère dans tree2)
while(count($tree1)>0){
foreach ($tree1 as $id => $dossier) {
if(in_array($dossier['dossier_parent_id'],$dossiersDejaCrees)){
// Le dossier pere de ce dossier a déja été créé dans tree2, on peut donc lancer les recherches...
$dossier['dossier_fils'] = array();
chercheIdDansTree($dossier['dossier_parent_id'],$dossier,$tree2,$id);
}
}
}
function chercheIdDansTree($id_a_trouver,$valeur_a_donner,&$tableau_a_explorer,$id_a_effacer_dans_tree1){
global $tree1,$dossiersDejaCrees;
echo("<hr> chercheIdDansTree(id_a_trouver=$id_a_trouver,valeur_a_donner=$valeur_a_donner,&tableau_a_explorer=$tableau_a_explorer,id_a_effacer_dans_tree1=$id_a_effacer_dans_tree1)
");
echo("valeur_a_donner : ");
print_r($valeur_a_donner);
echo("
");
echo("tableau_a_explorer : ");
print_r($tableau_a_explorer);
echo("
");
foreach ($tableau_a_explorer as $id => $dossier) {
echo('foreach ($tableau_a_explorer as $id = > $dossier)');
echo('id : ');
print_r($id);
echo('
');
echo('dossier : ');
print_r($dossier);
echo('
');
if(isset($dossier['dossier_id'])){
echo('$dossier[\'dossier_id\'] is set : '.$dossier['dossier_id'].'
');
if($dossier['dossier_id']==$id_a_trouver){
echo('$dossier[\'dossier_id\']==$id_a_trouver
');
rempliBranche($tableau_a_explorer[$id],'dossier_fils',$valeur_a_donner);
unset($tree1[$id_a_effacer_dans_tree1]);
$dossiersDejaCrees[] = $id_a_effacer_dans_tree1;
echo('unset($tree1[$id_a_effacer_dans_tree1='.$id_a_effacer_dans_tree1.']);
');
break;
}
elseif(count($dossier['dossier_fils'])>0){
chercheIdDansTree($id_a_trouver,$valeur_a_donner,$dossier['dossier_fils'],$id_a_effacer_dans_tree1);
}
}
else{
if(is_array($dossier)){
chercheIdDansTree($id_a_trouver,$valeur_a_donner,$dossier,$id_a_effacer_dans_tree1);
}
}
echo('');
}
}
function rempliBranche(&$branche,$cle,$valeur){
global $tree2;
echo(" rempliBranche(&branche=$branche,cle=$cle,valeur=$valeur) ");
echo('branche : ');
print_r($branche);
echo('
');
echo('valeur : ');
print_r($valeur);
echo('
');
$branche[$cle][] = $valeur;
echo('**** APRES **** : branche : ');
print_r($branche);
echo('
');
echo('**** APRES **** : tree2 : ');
print_r($tree2);
echo('
');
}
echo('<hr><hr><hr>tree2 : ');
print_r($tree2);
echo('
');
echo('<hr><hr><hr>tree1 : ');
print_r($tree1);
echo('
<hr><hr><hr>');
DEBUG :
tree1 : Array
(
[0] => Array
(
[dossier_id] = > 11
[dossier_parent_id] => 4
[dossier_nom] => 12 janvier 2008
)
[1] => Array
(
[dossier_id] => 10
[dossier_parent_id] => 4
[dossier_nom] => 15 mars 2008
)
[3] => Array
(
[dossier_id] => 4
[dossier_parent_id] => 1
[dossier_nom] => Simon
)
[4] => Array
(
[dossier_id] => 7
[dossier_parent_id] => 3
[dossier_nom] => Simon
)
[5] => Array
(
[dossier_id] => 5
[dossier_parent_id] => 1
[dossier_nom] => Marcel
)
[6] => Array
(
[dossier_id] => 9
[dossier_parent_id] => 3
[dossier_nom] => Marcel
)
[7] => Array
(
[dossier_id] => 8
[dossier_parent_id] => 3
[dossier_nom] => Maria
)
[8] => Array
(
[dossier_id] => 6
[dossier_parent_id] => 1
[dossier_nom] => Maria
)
)
<hr /><hr /><hr />tree2 : Array
(
[0] => Array
(
[dossier_id] => 3
[dossier_parent_id] => 0
[dossier_nom] => Autres
[dossier_fils] => Array
(
)
)
[1] => Array
(
[dossier_id] => 1
[dossier_parent_id] => 0
[dossier_nom] => Contrats
[dossier_fils] => Array
(
)
)
[2] => Array
(
[dossier_id] => 2
[dossier_parent_id] => 0
[dossier_nom] => Lettres
[dossier_fils] => Array
(
)
)
)
<hr /><hr /><hr /><hr /> chercheIdDansTree(id_a_trouver=1,valeur_a_donner=Array,&tableau_a_explorer=Array,id_a_effacer_dans_tree1=3)
valeur_a_donner : Array
(
[dossier_id] => 4
[dossier_parent_id] = > 1
[dossier_nom] => Simon
[dossier_fils] => Array
(
)
)
tableau_a_explorer : Array
(
[0] => Array
(
[dossier_id] => 3
[dossier_parent_id] => 0
[dossier_nom] => Autres
[dossier_fils] => Array
(
)
)
[1] => Array
(
[dossier_id] => 1
[dossier_parent_id] => 0
[dossier_nom] => Contrats
[dossier_fils] => Array
(
)
)
[2] => Array
(
[dossier_id] => 2
[dossier_parent_id] => 0
[dossier_nom] => Lettres
[dossier_fils] => Array
(
)
)
)
foreach ($tableau_a_explorer as $id => $dossier) id : 0
dossier : Array
(
[dossier_id] => 3
[dossier_parent_id] = > 0
[dossier_nom] => Autres
[dossier_fils] => Array
(
)
)
$dossier['dossier_id'] is set : 3
foreach ($tableau_a_explorer as $id => $dossier) id : 1
dossier : Array
(
[dossier_id] => 1
[dossier_parent_id] = > 0
[dossier_nom] => Contrats
[dossier_fils] => Array
(
)
)
$dossier['dossier_id'] is set :
1
$dossier['dossier_id']==$id_a_trouver
rempliBranche(&branche=Array,cle=dossier_fils,valeur=Array) branche : Array
(
[dossier_id] => 1
[dossier_parent_id] = > 0
[dossier_nom] => Contrats
[dossier_fils] => Array
(
)
)
valeur : Array
(
[dossier_id] => 4
[dossier_parent_id] => 1
[dossier_nom] => Simon
[dossier_fils] => Array
(
)
)
**** APRES **** : branche : Array
(
[dossier_id] => 1
[dossier_parent_id] => 0
[dossier_nom] => Contrats
[dossier_fils] => Array
(
[0] => Array
(
[dossier_id] => 4
[dossier_parent_id] => 1
[dossier_nom] => BERNARD Simon
[dossier_fils] => Array
(
)
)
)
)
**** APRES **** : tree2 : Array
(
[0] => Array
(
[dossier_id] => 3
[dossier_parent_id] => 0
[dossier_nom] => Autres
[dossier_fils] => Array
(
)
)
[1] => Array
(
[dossier_id] => 1
[dossier_parent_id] => 0
[dossier_nom] => Contrats
[dossier_fils] => Array
(
[0] => Array
(
[dossier_id] => 4
[dossier_parent_id] => 1
[dossier_nom] => Simon
[dossier_fils] => Array
(
)
)
)
)
[2] => Array
(
[dossier_id] => 2
[dossier_parent_id] => 0
[dossier_nom] => Lettres
[dossier_fils] => Array
(
)
)
)
unset($tree1[$id_a_effacer_dans_tree1=3]);
<hr /> chercheIdDansTree(id_a_trouver=3,valeur_a_donner=Array,&tableau_a_explorer=Array,id_a_effacer_dans_tree1=4)
valeur_a_donner : Array
(
[dossier_id] => 7
[dossier_parent_id] = > 3
[dossier_nom] => Simon
[dossier_fils] => Array
(
)
)
tableau_a_explorer : Array
(
[0] => Array
(
[dossier_id] => 3
[dossier_parent_id] => 0
[dossier_nom] => Autres
[dossier_fils] => Array
(
)
)
[1] => Array
(
[dossier_id] => 1
[dossier_parent_id] => 0
[dossier_nom] => Contrats
[dossier_fils] => Array
(
[0] => Array
(
[dossier_id] => 4
[dossier_parent_id] => 1
[dossier_nom] => Simon
[dossier_fils] => Array
(
)
)
)
)
[2] => Array
(
[dossier_id] => 2
[dossier_parent_id] => 0
[dossier_nom] => Lettres
[dossier_fils] => Array
(
)
)
)
foreach ($tableau_a_explorer as $id => $dossier) id : 0
dossier : Array
(
[dossier_id] => 3
[dossier_parent_id] = > 0
[dossier_nom] => Autres
[dossier_fils] => Array
(
)
)
$dossier['dossier_id'] is set :
3
$dossier['dossier_id']==$id_a_trouver
rempliBranche(&branche=Array,cle=dossier_fils,valeur=Array) branche : Array
(
[dossier_id] => 3
[dossier_parent_id] = > 0
[dossier_nom] => Autres
[dossier_fils] => Array
(
)
)
valeur : Array
(
[dossier_id] => 7
[dossier_parent_id] => 3
[dossier_nom] => Simon
[dossier_fils] => Array
(
)
)
**** APRES **** : branche : Array
(
[dossier_id] => 3
[dossier_parent_id] => 0
[dossier_nom] => Autres
[dossier_fils] => Array
(
[0] => Array
(
[dossier_id] => 7
[dossier_parent_id] => 3
[dossier_nom] => Simon
[dossier_fils] => Array
(
)
)
)
)
**** APRES **** : tree2 : Array
(
[0] => Array
(
[dossier_id] => 3
[dossier_parent_id] => 0
[dossier_nom] => Autres
[dossier_fils] => Array
(
[0] => Array
(
[dossier_id] => 7
[dossier_parent_id] => 3
[dossier_nom] => Simon
[dossier_fils] => Array
(
)
)
)
)
[1] => Array
(
[dossier_id] => 1
[dossier_parent_id] => 0
[dossier_nom] => Contrats
[dossier_fils] => Array
(
[0] => Array
(
[dossier_id] => 4
[dossier_parent_id] => 1
[dossier_nom] => Simon
[dossier_fils] => Array
(
)
)
)
)
[2] => Array
(
[dossier_id] => 2
[dossier_parent_id] => 0
[dossier_nom] => Lettres
[dossier_fils] => Array
(
)
)
)
unset($tree1[$id_a_effacer_dans_tree1=4]);
<hr /> chercheIdDansTree(id_a_trouver=1,valeur_a_donner=Array,&tableau_a_explorer=Array,id_a_effacer_dans_tree1=5)
valeur_a_donner : Array
(
[dossier_id] => 5
[dossier_parent_id] = > 1
[dossier_nom] => Marcel
[dossier_fils] => Array
(
)
)
tableau_a_explorer : Array
(
[0] => Array
(
[dossier_id] => 3
[dossier_parent_id] => 0
[dossier_nom] => Autres
[dossier_fils] => Array
(
[0] => Array
(
[dossier_id] => 7
[dossier_parent_id] => 3
[dossier_nom] => Simon
[dossier_fils] => Array
(
)
)
)
)
[1] => Array
(
[dossier_id] => 1
[dossier_parent_id] => 0
[dossier_nom] => Contrats
[dossier_fils] => Array
(
[0] => Array
(
[dossier_id] => 4
[dossier_parent_id] => 1
[dossier_nom] => Simon
[dossier_fils] => Array
(
)
)
)
)
[2] => Array
(
[dossier_id] => 2
[dossier_parent_id] => 0
[dossier_nom] => Lettres
[dossier_fils] => Array
(
)
)
)
foreach ($tableau_a_explorer as $id => $dossier) id : 0
dossier : Array
(
[dossier_id] => 3
[dossier_parent_id] = > 0
[dossier_nom] => Autres
[dossier_fils] => Array
(
[0] => Array
(
[dossier_id] => 7
[dossier_parent_id] => 3
[dossier_nom] => Simon
[dossier_fils] => Array
(
)
)
)
)
$dossier['dossier_id'] is set : 3
<hr /> chercheIdDansTree(id_a_trouver=1,valeur_a_donner=Array,&tableau_a_explorer=Array,id_a_effacer_dans_tree1=5)
valeur_a_donner : Array
(
[dossier_id] => 5
[dossier_parent_id] = > 1
[dossier_nom] => Marcel
[dossier_fils] => Array
(
)
)
tableau_a_explorer : Array
(
[0] => Array
(
[dossier_id] => 7
[dossier_parent_id] => 3
[dossier_nom] => Simon
[dossier_fils] => Array
(
)
)
)
foreach ($tableau_a_explorer as $id => $dossier) id : 0
dossier : Array
(
[dossier_id] => 7
[dossier_parent_id] = > 3
[dossier_nom] => Simon
[dossier_fils] => Array
(
)
)
$dossier['dossier_id'] is set : 7
foreach ($tableau_a_explorer as $id => $dossier) id : 1
dossier : Array
(
[dossier_id] => 1
[dossier_parent_id] = > 0
[dossier_nom] => Contrats
[dossier_fils] => Array
(
[0] => Array
(
[dossier_id] => 4
[dossier_parent_id] => 1
[dossier_nom] => Simon
[dossier_fils] => Array
(
)
)
)
)
$dossier['dossier_id'] is set :
1
$dossier['dossier_id']==$id_a_trouver
rempliBranche(&branche=Array,cle=dossier_fils,valeur=Array) branche : Array
(
[dossier_id] => 1
[dossier_parent_id] = > 0
[dossier_nom] => Contrats
[dossier_fils] => Array
(
[0] => Array
(
[dossier_id] => 4
[dossier_parent_id] => 1
[dossier_nom] => Simon
[dossier_fils] => Array
(
)
)
)
)
valeur : Array
(
[dossier_id] => 5
[dossier_parent_id] => 1
[dossier_nom] => Marcel
[dossier_fils] => Array
(
)
)
**** APRES **** : branche : Array
(
[dossier_id] => 1
[dossier_parent_id] => 0
[dossier_nom] => Contrats
[dossier_fils] => Array
(
[0] => Array
(
[dossier_id] => 4
[dossier_parent_id] => 1
[dossier_nom] => Simon
[dossier_fils] => Array
(
)
)
[1] => Array
(
[dossier_id] => 5
[dossier_parent_id] => 1
[dossier_nom] => Marcel
[dossier_fils] => Array
(
)
)
)
)
**** APRES **** : tree2 : Array
(
[0] => Array
(
[dossier_id] => 3
[dossier_parent_id] => 0
[dossier_nom] => Autres
[dossier_fils] => Array
(
[0] => Array
(
[dossier_id] => 7
[dossier_parent_id] => 3
[dossier_nom] => Simon
[dossier_fils] => Array
(
)
)
)
)
[1] => Array
(
[dossier_id] => 1
[dossier_parent_id] => 0
[dossier_nom] => Contrats
[dossier_fils] => Array
(
[0] => Array
(
[dossier_id] => 4
[dossier_parent_id] => 1
[dossier_nom] => Simon
[dossier_fils] => Array
(
)
)
[1] => Array
(
[dossier_id] => 5
[dossier_parent_id] => 1
[dossier_nom] => Marcel
[dossier_fils] => Array
(
)
)
)
)
[2] => Array
(
[dossier_id] => 2
[dossier_parent_id] => 0
[dossier_nom] => Lettres
[dossier_fils] => Array
(
)
)
)
unset($tree1[$id_a_effacer_dans_tree1=5]);
<hr /> chercheIdDansTree(id_a_trouver=3,valeur_a_donner=Array,&tableau_a_explorer=Array,id_a_effacer_dans_tree1=6)
valeur_a_donner : Array
(
[dossier_id] => 9
[dossier_parent_id] = > 3
[dossier_nom] => Marcel
[dossier_fils] => Array
(
)
)
tableau_a_explorer : Array
(
[0] => Array
(
[dossier_id] => 3
[dossier_parent_id] => 0
[dossier_nom] => Autres
[dossier_fils] => Array
(
[0] => Array
(
[dossier_id] => 7
[dossier_parent_id] => 3
[dossier_nom] => Simon
[dossier_fils] => Array
(
)
)
)
)
[1] => Array
(
[dossier_id] => 1
[dossier_parent_id] => 0
[dossier_nom] => Contrats
[dossier_fils] => Array
(
[0] => Array
(
[dossier_id] => 4
[dossier_parent_id] => 1
[dossier_nom] => Simon
[dossier_fils] => Array
(
)
)
[1] => Array
(
[dossier_id] => 5
[dossier_parent_id] => 1
[dossier_nom] => Marcel
[dossier_fils] => Array
(
)
)
)
)
[2] => Array
(
[dossier_id] => 2
[dossier_parent_id] => 0
[dossier_nom] => Lettres
[dossier_fils] => Array
(
)
)
)
foreach ($tableau_a_explorer as $id => $dossier) id : 0
dossier : Array
(
[dossier_id] => 3
[dossier_parent_id] = > 0
[dossier_nom] => Autres
[dossier_fils] => Array
(
[0] => Array
(
[dossier_id] => 7
[dossier_parent_id] => 3
[dossier_nom] => Simon
[dossier_fils] => Array
(
)
)
)
)
$dossier['dossier_id'] is set :
3
$dossier['dossier_id']==$id_a_trouver
rempliBranche(&branche=Array,cle=dossier_fils,valeur=Array) branche : Array
(
[dossier_id] => 3
[dossier_parent_id] = > 0
[dossier_nom] => Autre
[dossier_fils] => Array
(
[0] => Array
(
[dossier_id] => 7
[dossier_parent_id] => 3
[dossier_nom] => Simon
[dossier_fils] => Array
(
)
)
)
)
valeur : Array
(
[dossier_id] => 9
[dossier_parent_id] => 3
[dossier_nom] => Marcel
[dossier_fils] => Array
(
)
)
**** APRES **** : branche : Array
(
[dossier_id] => 3
[dossier_parent_id] => 0
[dossier_nom] => Autres
[dossier_fils] => Array
(
[0] => Array
(
[dossier_id] => 7
[dossier_parent_id] => 3
[dossier_nom] => Simon
[dossier_fils] => Array
(
)
)
[1] => Array
(
[dossier_id] => 9
[dossier_parent_id] => 3
[dossier_nom] => Marcel
[dossier_fils] => Array
(
)
)
)
)
**** APRES **** : tree2 : Array
(
[0] => Array
(
[dossier_id] => 3
[dossier_parent_id] => 0
[dossier_nom] => Autres
[dossier_fils] => Array
(
[0] => Array
(
[dossier_id] => 7
[dossier_parent_id] => 3
[dossier_nom] => Simon
[dossier_fils] => Array
(
)
)
[1] => Array
(
[dossier_id] => 9
[dossier_parent_id] => 3
[dossier_nom] => Marcel
[dossier_fils] => Array
(
)
)
)
)
[1] => Array
(
[dossier_id] => 1
[dossier_parent_id] => 0
[dossier_nom] => Contrats
[dossier_fils] => Array
(
[0] => Array
(
[dossier_id] => 4
[dossier_parent_id] => 1
[dossier_nom] => Simon
[dossier_fils] => Array
(
)
)
[1] => Array
(
[dossier_id] => 5
[dossier_parent_id] => 1
[dossier_nom] => Marcel
[dossier_fils] => Array
(
)
)
)
)
[2] => Array
(
[dossier_id] => 2
[dossier_parent_id] => 0
[dossier_nom] => Lettres
[dossier_fils] => Array
(
)
)
)
unset($tree1[$id_a_effacer_dans_tree1=6]);
<hr /> chercheIdDansTree(id_a_trouver=3,valeur_a_donner=Array,&tableau_a_explorer=Array,id_a_effacer_dans_tree1=7)
valeur_a_donner : Array
(
[dossier_id] => 8
[dossier_parent_id] = > 3
[dossier_nom] => Maria
[dossier_fils] => Array
(
)
)
tableau_a_explorer : Array
(
[0] => Array
(
[dossier_id] => 3
[dossier_parent_id] => 0
[dossier_nom] => Autres
[dossier_fils] => Array
(
[0] => Array
(
[dossier_id] => 7
[dossier_parent_id] => 3
[dossier_nom] => Simon
[dossier_fils] => Array
(
)
)
[1] => Array
(
[dossier_id] => 9
[dossier_parent_id] => 3
[dossier_nom] => Marcel
[dossier_fils] => Array
(
)
)
)
)
[1] => Array
(
[dossier_id] => 1
[dossier_parent_id] => 0
[dossier_nom] => Contrats
[dossier_fils] => Array
(
[0] => Array
(
[dossier_id] => 4
[dossier_parent_id] => 1
[dossier_nom] => Simon
[dossier_fils] => Array
(
)
)
[1] => Array
(
[dossier_id] => 5
[dossier_parent_id] => 1
[dossier_nom] => Marcel
[dossier_fils] => Array
(
)
)
)
)
[2] => Array
(
[dossier_id] => 2
[dossier_parent_id] => 0
[dossier_nom] => Lettres
[dossier_fils] => Array
(
)
)
)
foreach ($tableau_a_explorer as $id => $dossier) id : 0
dossier : Array
(
[dossier_id] => 3
[dossier_parent_id] = > 0
[dossier_nom] => Autres
[dossier_fils] => Array
(
[0] => Array
(
[dossier_id] => 7
[dossier_parent_id] => 3
[dossier_nom] => Simon
[dossier_fils] => Array
(
)
)
[1] => Array
(
[dossier_id] => 9
[dossier_parent_id] => 3
[dossier_nom] => Marcel
[dossier_fils] => Array
(
)
)
)
)
$dossier['dossier_id'] is set :
3
$dossier['dossier_id']==$id_a_trouver
rempliBranche(&branche=Array,cle=dossier_fils,valeur=Array) branche : Array
(
[dossier_id] => 3
[dossier_parent_id] = > 0
[dossier_nom] => Autres
[dossier_fils] => Array
(
[0] => Array
(
[dossier_id] => 7
[dossier_parent_id] => 3
[dossier_nom] => Simon
[dossier_fils] => Array
(
)
)
[1] => Array
(
[dossier_id] => 9
[dossier_parent_id] => 3
[dossier_nom] => Marcel
[dossier_fils] => Array
(
)
)
)
)
valeur : Array
(
[dossier_id] => 8
[dossier_parent_id] => 3
[dossier_nom] => Maria
[dossier_fils] => Array
(
)
)
**** APRES **** : branche : Array
(
[dossier_id] => 3
[dossier_parent_id] => 0
[dossier_nom] => Autres
[dossier_fils] => Array
(
[0] => Array
(
[dossier_id] => 7
[dossier_parent_id] => 3
[dossier_nom] => Simon
[dossier_fils] => Array
(
)
)
[1] => Array
(
[dossier_id] => 9
[dossier_parent_id] => 3
[dossier_nom] => Marcel
[dossier_fils] => Array
(
)
)
[2] => Array
(
[dossier_id] => 8
[dossier_parent_id] => 3
[dossier_nom] => Maria
[dossier_fils] => Array
(
)
)
)
)
**** APRES **** : tree2 : Array
(
[0] => Array
(
[dossier_id] => 3
[dossier_parent_id] => 0
[dossier_nom] => Autres
[dossier_fils] => Array
(
[0] => Array
(
[dossier_id] => 7
[dossier_parent_id] => 3
[dossier_nom] => Simon
[dossier_fils] => Array
(
)
)
[1] => Array
(
[dossier_id] => 9
[dossier_parent_id] => 3
[dossier_nom] => Marcel
[dossier_fils] => Array
(
)
)
[2] => Array
(
[dossier_id] => 8
[dossier_parent_id] => 3
[dossier_nom] => Maria
[dossier_fils] => Array
(
)
)
)
)
[1] => Array
(
[dossier_id] => 1
[dossier_parent_id] => 0
[dossier_nom] => Contrats
[dossier_fils] => Array
(
[0] => Array
(
[dossier_id] => 4
[dossier_parent_id] => 1
[dossier_nom] => Simon
[dossier_fils] => Array
(
)
)
[1] => Array
(
[dossier_id] => 5
[dossier_parent_id] => 1
[dossier_nom] => Marcel
[dossier_fils] => Array
(
)
)
)
)
[2] => Array
(
[dossier_id] => 2
[dossier_parent_id] => 0
[dossier_nom] => Lettres
[dossier_fils] => Array
(
)
)
)
unset($tree1[$id_a_effacer_dans_tree1=7]);
<hr /> chercheIdDansTree(id_a_trouver=1,valeur_a_donner=Array,&tableau_a_explorer=Array,id_a_effacer_dans_tree1=8)
valeur_a_donner : Array
(
[dossier_id] => 6
[dossier_parent_id] = > 1
[dossier_nom] => Maria
[dossier_fils] => Array
(
)
)
tableau_a_explorer : Array
(
[0] => Array
(
[dossier_id] => 3
[dossier_parent_id] => 0
[dossier_nom] => utres
[dossier_fils] => Array
(
[0] => Array
(
[dossier_id] => 7
[dossier_parent_id] => 3
[dossier_nom] => Simon
[dossier_fils] => Array
(
)
)
[1] => Array
(
[dossier_id] => 9
[dossier_parent_id] => 3
[dossier_nom] => Marcel
[dossier_fils] => Array
(
)
)
[2] => Array
(
[dossier_id] => 8
[dossier_parent_id] => 3
[dossier_nom] => Maria
[dossier_fils] => Array
(
)
)
)
)
[1] => Array
(
[dossier_id] => 1
[dossier_parent_id] => 0
[dossier_nom] => Contrats
[dossier_fils] => Array
(
[0] => Array
(
[dossier_id] => 4
[dossier_parent_id] => 1
[dossier_nom] => Simon
[dossier_fils] => Array
(
)
)
[1] => Array
(
[dossier_id] => 5
[dossier_parent_id] => 1
[dossier_nom] => Marcel
[dossier_fils] => Array
(
)
)
)
)
[2] => Array
(
[dossier_id] => 2
[dossier_parent_id] => 0
[dossier_nom] => Lettres
[dossier_fils] => Array
(
)
)
)
foreach ($tableau_a_explorer as $id => $dossier) id : 0
dossier : Array
(
[dossier_id] => 3
[dossier_parent_id] = > 0
[dossier_nom] => Autres
[dossier_fils] => Array
(
[0] => Array
(
[dossier_id] => 7
[dossier_parent_id] => 3
[dossier_nom] => Simon
[dossier_fils] => Array
(
)
)
[1] => Array
(
[dossier_id] => 9
[dossier_parent_id] => 3
[dossier_nom] => Marcel
[dossier_fils] => Array
(
)
)
[2] => Array
(
[dossier_id] => 8
[dossier_parent_id] => 3
[dossier_nom] => Maria
[dossier_fils] => Array
(
)
)
)
)
$dossier['dossier_id'] is set : 3
<hr /> chercheIdDansTree(id_a_trouver=1,valeur_a_donner=Array,&tableau_a_explorer=Array,id_a_effacer_dans_tree1=8)
valeur_a_donner : Array
(
[dossier_id] => 6
[dossier_parent_id] = > 1
[dossier_nom] => Maria
[dossier_fils] => Array
(
)
)
tableau_a_explorer : Array
(
[0] => Array
(
[dossier_id] => 7
[dossier_parent_id] => 3
[dossier_nom] => Simon
[dossier_fils] => Array
(
)
)
[1] => Array
(
[dossier_id] => 9
[dossier_parent_id] => 3
[dossier_nom] => Marcel
[dossier_fils] => Array
(
)
)
[2] => Array
(
[dossier_id] => 8
[dossier_parent_id] => 3
[dossier_nom] => Maria
[dossier_fils] => Array
(
)
)
)
foreach ($tableau_a_explorer as $id => $dossier) id : 0
dossier : Array
(
[dossier_id] => 7
[dossier_parent_id] = > 3
[dossier_nom] => Simon
[dossier_fils] => Array
(
)
)
$dossier['dossier_id'] is set : 7
foreach ($tableau_a_explorer as $id => $dossier) id : 1
dossier : Array
(
[dossier_id] => 9
[dossier_parent_id] = > 3
[dossier_nom] => Marcel
[dossier_fils] => Array
(
)
)
$dossier['dossier_id'] is set : 9
foreach ($tableau_a_explorer as $id => $dossier) id : 2
dossier : Array
(
[dossier_id] => 8
[dossier_parent_id] = > 3
[dossier_nom] => Maria
[dossier_fils] => Array
(
)
)
$dossier['dossier_id'] is set : 8
foreach ($tableau_a_explorer as $id => $dossier) id : 1
dossier : Array
(
[dossier_id] => 1
[dossier_parent_id] = > 0
[dossier_nom] => Contrats
[dossier_fils] => Array
(
[0] => Array
(
[dossier_id] => 4
[dossier_parent_id] => 1
[dossier_nom] => Simon
[dossier_fils] => Array
(
)
)
[1] => Array
(
[dossier_id] => 5
[dossier_parent_id] => 1
[dossier_nom] => Marcel
[dossier_fils] => Array
(
)
)
)
)
$dossier['dossier_id'] is set :
1
$dossier['dossier_id']==$id_a_trouver
rempliBranche(&branche=Array,cle=dossier_fils,valeur=Array) branche : Array
(
[dossier_id] => 1
[dossier_parent_id] = > 0
[dossier_nom] => Contrats
[dossier_fils] => Array
(
[0] => Array
(
[dossier_id] => 4
[dossier_parent_id] => 1
[dossier_nom] => Simon
[dossier_fils] => Array
(
)
)
[1] => Array
(
[dossier_id] => 5
[dossier_parent_id] => 1
[dossier_nom] => Marcel
[dossier_fils] => Array
(
)
)
)
)
valeur : Array
(
[dossier_id] => 6
[dossier_parent_id] => 1
[dossier_nom] => Maria
[dossier_fils] => Array
(
)
)
**** APRES **** : branche : Array
(
[dossier_id] => 1
[dossier_parent_id] => 0
[dossier_nom] => Contrats
[dossier_fils] => Array
(
[0] => Array
(
[dossier_id] => 4
[dossier_parent_id] => 1
[dossier_nom] => Simon
[dossier_fils] => Array
(
)
)
[1] => Array
(
[dossier_id] => 5
[dossier_parent_id] => 1
[dossier_nom] => Marcel
[dossier_fils] => Array
(
)
)
[2] => Array
(
[dossier_id] => 6
[dossier_parent_id] => 1
[dossier_nom] => Maria
[dossier_fils] => Array
(
)
)
)
)
**** APRES **** : tree2 : Array
(
[0] => Array
(
[dossier_id] => 3
[dossier_parent_id] => 0
[dossier_nom] => Autres
[dossier_fils] => Array
(
[0] => Array
(
[dossier_id] => 7
[dossier_parent_id] => 3
[dossier_nom] => Simon
[dossier_fils] => Array
(
)
)
[1] => Array
(
[dossier_id] => 9
[dossier_parent_id] => 3
[dossier_nom] => Marcel
[dossier_fils] => Array
(
)
)
[2] => Array
(
[dossier_id] => 8
[dossier_parent_id] => 3
[dossier_nom] => Maria
[dossier_fils] => Array
(
)
)
)
)
[1] => Array
(
[dossier_id] => 1
[dossier_parent_id] => 0
[dossier_nom] => Contrats
[dossier_fils] => Array
(
[0] => Array
(
[dossier_id] => 4
[dossier_parent_id] => 1
[dossier_nom] => Simon
[dossier_fils] => Array
(
)
)
[1] => Array
(
[dossier_id] => 5
[dossier_parent_id] => 1
[dossier_nom] => Marcel
[dossier_fils] => Array
(
)
)
[2] => Array
(
[dossier_id] => 6
[dossier_parent_id] => 1
[dossier_nom] => Maria
[dossier_fils] => Array
(
)
)
)
)
[2] => Array
(
[dossier_id] => 2
[dossier_parent_id] => 0
[dossier_nom] => Lettres
[dossier_fils] => Array
(
)
)
)
unset($tree1[$id_a_effacer_dans_tree1=8]);
<hr /> chercheIdDansTree(id_a_trouver=4,valeur_a_donner=Array,&tableau_a_explorer=Array,id_a_effacer_dans_tree1=0)
valeur_a_donner : Array
(
[dossier_id] => 11
[dossier_parent_id] = > 4
[dossier_nom] => 12/01/2008
[dossier_fils] => Array
(
)
)
tableau_a_explorer : Array
(
[0] => Array
(
[dossier_id] => 3
[dossier_parent_id] => 0
[dossier_nom] => Autres
[dossier_fils] => Array
(
[0] => Array
(
[dossier_id] => 7
[dossier_parent_id] => 3
[dossier_nom] => Simon
[dossier_fils] => Array
(
)
)
[1] => Array
(
[dossier_id] => 9
[dossier_parent_id] => 3
[dossier_nom] => Marcel
[dossier_fils] => Array
(
)
)
[2] => Array
(
[dossier_id] => 8
[dossier_parent_id] => 3
[dossier_nom] => Maria
[dossier_fils] => Array
(
)
)
)
)
[1] => Array
(
[dossier_id] => 1
[dossier_parent_id] => 0
[dossier_nom] => Contrats
[dossier_fils] => Array
(
[0] => Array
(
[dossier_id] => 4
[dossier_parent_id] => 1
[dossier_nom] => Simon
[dossier_fils] => Array
(
)
)
[1] => Array
(
[dossier_id] => 5
[dossier_parent_id] => 1
[dossier_nom] => Marcel
[dossier_fils] => Array
(
)
)
[2] => Array
(
[dossier_id] => 6
[dossier_parent_id] => 1
[dossier_nom] => Maria
[dossier_fils] => Array
(
)
)
)