Bonjour,

Je souhaiterais afficher les données d'un tableau. Il s'agit en fait des prestations d'un hébergement qui se décompose en plusieurs catégories (activités, conforts, équipements, etc.)
Je n'arrive pas à afficher les données comprises dans chacune de ces catégories.

Voici à quoi ressemble mon tableau :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
 
 ["OffresPrestations"]=>
          array(1) {
            ["DetailOffrePrestation"]=>
            array(3) {
              [0]=>
              array(3) {
                ["Type"]=>
                string(5) "15.02"
                ["Libelle"]=>
                string(9) "Activités"
                ["Prestations"]=>
                array(1) {
                  ["DetailPrestation"]=>
                  array(2) {
                    [0]=>
                    array(2) {
                      ["Type"]=>
                      string(8) "15.02.39"
                      ["Libelle"]=>
                      string(18) "Randonnée pédestre"
                    }
                    [1]=>
                    array(2) {
                      ["Type"]=>
                      string(8) "15.02.58"
                      ["Libelle"]=>
                      string(6) "Tennis"
                    }
                  }
                }
              }
              [1]=>
              array(3) {
                ["Type"]=>
                string(5) "15.05"
                ["Libelle"]=>
                string(11) "Equipements"
                ["Prestations"]=>
                array(1) {
                  ["DetailPrestation"]=>
                  array(4) {
                    [0]=>
                    array(2) {
                      ["Type"]=>
                      string(9) "15.05.123"
                      ["Libelle"]=>
                      string(8) "Terrasse"
                    }
                    [1]=>
                    array(2) {
                      ["Type"]=>
                      string(8) "15.05.48"
                      ["Libelle"]=>
                      string(6) "Jardin"
                    }
                    [2]=>
                    array(2) {
                      ["Type"]=>
                      string(8) "15.05.49"
                      ["Libelle"]=>
                      string(13) "Jardin commun"
                    }
                    [3]=>
                    array(2) {
                      ["Type"]=>
                      string(8) "15.05.43"
                      ["Libelle"]=>
                      string(23) "Habitation indépendante"
                    }
                  }
                }
              }
              [2]=>
              array(3) {
                ["Type"]=>
                string(5) "15.06"
                ["Libelle"]=>
                string(8) "Services"
                ["Prestations"]=>
                array(1) {
                  ["DetailPrestation"]=>
                  array(2) {
                    [0]=>
                    array(2) {
                      ["Type"]=>
                      string(8) "15.06.26"
                      ["Libelle"]=>
                      string(9) "Commerces"
                    }
                    [1]=>
                    array(2) {
                      ["Type"]=>
                      string(8) "15.06.05"
                      ["Libelle"]=>
                      string(16) "Animaux acceptés"
                    }
                  }
                }
              }
            }
          }
Et voici le code que j'utilise pour tenter d'afficher les prestations :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
 
// on définit les prestations
$prestations_objet = $objet_sitra[OffresPrestations];
 
// on affiche les prestations
foreach($prestations_objet[DetailOffrePrestation] as $presta)
{
   // on affiche les activités
   if($presta[Type] == '15.02')
   {
      echo "Activités : ";
      foreach($prestations_objet[DetailOffrePrestation][Prestations] as $presta2)
      {							
         echo $presta2[DetailPrestation][Libelle]." - ";
      }
   // on affiche les équipements
   if($presta[Type] == '15.05')
   {
      echo "Equipements : ";
      foreach($prestations_objet[DetailOffrePrestation][Prestations] as $presta2)
      {							
         echo $presta2[DetailPrestation][Libelle]." - ";
      }
   etc.
}
Le titre des catégories apparaît bien mais pas le nom des prestations. Peut-on faire des "foreach" imbriqués ? Quel est le problème ?