I am trying to create a 2-dimensional array, reading specific values from a (large) met file. The arrays are empty and I dont know why. I have the following array:
$varmet = array('tasmax', 'tasmin', 'pr', 'clt');
I have two loops:
The first is
for ($j = 0; $j <= 3; $j++) {
...
I read the corresponding files and variables, etc. It works properly.
Then I have the other loop
for ($i = 1; $i <= 360; $i++) {
....
$valor = $valor * $correctp;
It works perfectly, retrieving the required value in $valor
The problem arise when I want to store the value in a different array, according to the met variable:
switch ($j) {
case 0:
$tmax[$i] = $valor;
break;
case 1:
$tmin[$i] = $valor;
break;
case 2:
$prec[] = $valor;
break;
case 3:
$clt[$i] = $valor;
break; } // Fin del switch
} // Fin del for para un fichero met
} // Fin del for para todas las varmet
The $tmax, $tmin, etc. have no value, although $valor does have. Furthermore, if I assign the array within the loop (i.e. $valorest[$j][$i] = $valor) it still have the values, but not outside it.
Anybody knows what I am doing wrong?