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
| $iterator =new RecursiveArrayIterator(new ArrayObject($arrayObj));
/*** traverse the $iterator object ***/
while($iterator->valid())
{
$iteratorbis = new RecursiveArrayIterator($iterator->current());
if ($iterator->key()!=0)
{
foreach($iteratorbis as $keys=>$values)
{
if ($keys == "Caracteristique" AND !in_array($values, $tblCaracteristiques))
{
$caract = $values;
$tblCaracteristiques[] = $values;
}
if ($keys == 'Type'){
$type = $values;
}
if ($keys == 'Nom_equipement'){
$nom = $values;
}
if ($keys == 'Valeur'){
$valeur = $values;
}
}
$tblEquipements[$type][$nom][$caract] = $valeur;
$tblTypes[$type][$caract]=$caract;
}
$iterator->next();
}
/*Parcours de la table de tous les type associé aux caractéristiques*/
foreach ($tblTypes as $type => $valeur){
/* Creation d'un table par type*/
echo"<table class=\"donnees\" border=\"1\" cellspacing=\"1\">";
echo '<thead><tr><td></td>';
/*Affichage des caractéristiques sur une ligne*/
foreach ($valeur as $carac )
{
echo "<th>$carac</th>";
}
echo "</tr></thead>";
/* Affichage du nom de l'equipement et des valeurs associé au caractéristique*/
foreach ($tblEquipements[$type] as $nom => $valeurs)
{
echo '<tr><td>';
echo "$nom</td>";
foreach ($tblTypes[$type] as $cacracteristique)
{
if (isset($valeurs[$cacracteristique])){
echo '<td>' . $valeurs[$cacracteristique] .'</td>';
}
else{
echo '<td> </td>';
}
}
}
echo "</tr>";
echo "</table>";
}
} |