Bonjour

Je remplis un tableau à partir d'un fichier .json.

Cela fonctionne mais sur les 5 lignes que compte mon tableau, une est incorrecte, l'index 1. Pourtant que j affiche les valeurs à insérer dans la boucle elle sont correctes.
Voici le resultat du vardump() sur le tableau avec en gras ce qui pose pb.
array (size=5)
0 =>
array (size=2)
'high' => int 22
'low' => int 22
1 =>
array (size=4)
0 => string 'high' (length=4)
1 => string 'low' (length=3)
'high' => float 28.876
'low' => float 28.75

2 =>
array (size=2)
'high' => float 27.376
'low' => float 27.25
3 =>
array (size=2)
'high' => float 25.376
'low' => float 25.25
4 =>
array (size=2)
'high' => int 26
'low' => float 25.876
Le code que j utilise :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
 
$data     = json_decode($jsonData, true);
$tab = array(array(), array("high", "low"));
for ($i = 0; $i < 5; $i++) {
 
                /* CET AFFICHAGE EST CORRECT */
		echo $i . ' -> ' . $data[$i]['high'] . ' / ' . $data[$i]['low'] . '<br/>';
 
		$tab[$i]['high'] = $data[$i]['high'];
		$tab[$i]['low']  = $data[$i]['low'];
	}
	var_dump($tab);
le résultat de mon affichage des valeurs dans la boucle est lui correct (en gras).
0 -> 22 / 22
1 -> 28.876 / 28.75
2 -> 27.376 / 27.25
3 -> 25.376 / 25.25
4 -> 26 / 25.876
Comme tout débutant j ai lu doc et tutaux mais là je pensais que cela était correct.

D'où vient mon pb et pourquoi ne se produit il qu une seule fois ?

Merci de vos éclairages et conseils.