1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
| //creation de mon arbre
public function constituerArbreRecursion($listeinstallations, $id, $arbre){
$var1 =0;
foreach($listeinstallations as $message){
if($message->InstallationPere == $id){
$arbre = $arbre." ".$message->Nom;
$this->listenoeud = $this->listenoeud .$message->InstallationPere.';'.$message->Nom .';' .$message->id.';';
$this->constituerArbreRecursion($listeinstallations, $message->id, $arbre);
}
}
return $arbre;
}
public function getTousLesInstallations(){
$listeinstallations = $this->installation_model->listeInstallations(); //récupération de mes valeurs
$arbre = $this->constituerArbre($listeinstallations, 0);
$valeur = array();
$valeur = (explode(';',$this->listenoeud)); // création de mon tableu
$valeur = array_filter($valeur, function($var){
return (!($var == '' || is_null($var))); // purge
});
echo json_encode ($valeur); //envoie de mon tableau |