I got troubles with multidimensional array in PHP because I lost some values when I try to add other informations in my array.
Here is my initial code :
$reponse = $bdd->query("select OrderDate, NomChaine, NomJob, Debut, Fin from ReportJobs where NomJob in ('NPT01000', 'NPT11999') order by OrderDate ASC;");
while ($donnees = $reponse->fetch())
{
$num_semaine = date('W', strtotime($donnees['OrderDate']));
$num_journee = date('N', strtotime($donnees['OrderDate']));
$retour[$num_semaine][$num_journee][substr($donnees['NomChaine'], 0, -2)][$donnees['NomJob']] = array(
'Debut' => $donnees['Debut'],
'Fin' => $donnees['Fin']
);
}
$reponse->closeCursor();
var_dump($retour['07']['1']);
Here is the (correct and wanted) output of the var_dump($retour['07']['1']); :

Then, I tried to store the value of 'OrderDate' in the $retour[$num_semaine][$num_journee] level.
Here is the new code :
$reponse = $bdd->query("select OrderDate, NomChaine, NomJob, Debut, Fin from ReportJobs where NomJob in ('NPT01000', 'NPT11999') order by OrderDate ASC;");
while ($donnees = $reponse->fetch())
{
$num_semaine = date('W', strtotime($donnees['OrderDate']));
$num_journee = date('N', strtotime($donnees['OrderDate']));
$retour[$num_semaine][$num_journee] = array(
'Date' => $donnees['OrderDate']
);
$retour[$num_semaine][$num_journee][substr($donnees['NomChaine'], 0, -2)][$donnees['NomJob']] = array(
'Debut' => $donnees['Debut'],
'Fin' => $donnees['Fin']
);
}
$reponse->closeCursor();
var_dump($retour['07']['1']);
var_dump($retour['07']['1']); :

Some values are now missing.
I tried it the other way around :
$reponse = $bdd->query("select OrderDate, NomChaine, NomJob, Debut, Fin from ReportJobs where NomJob in ('NPT01000', 'NPT11999') order by OrderDate ASC;");
while ($donnees = $reponse->fetch())
{
$num_semaine = date('W', strtotime($donnees['OrderDate']));
$num_journee = date('N', strtotime($donnees['OrderDate']));
$retour[$num_semaine][$num_journee][substr($donnees['NomChaine'], 0, -2)][$donnees['NomJob']] = array(
'Debut' => $donnees['Debut'],
'Fin' => $donnees['Fin']
);
$retour[$num_semaine][$num_journee] = array(
'Date' => $donnees['OrderDate']
);
}
$reponse->closeCursor();
var_dump($retour['07']['1']);
var_dump($retour['07']['1']); :

It looks like the second instructions erased all the things written with the first one.
Anyone got an idea on how I can make this right ?
Thanks to all of you who read till the end.