English 中文(简体)
配电机外的硬套阵列
原标题:Cant retrieve PHP arrays outside the assigning loop
  • 时间:2012-05-02 06:13:52
  •  标签:
  • php

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 = 阵列(tasmax ,tasmin ,pr , clt );

我有两个机会:

第一是

for ($j = 0; $j <= 3; $j++)  {
...

我读到相应的档案和变量等。 它运作正常。

然后,我有另一处 lo。

for ($i = 1; $i <= 360; $i++) {
....
$valor = $valor * $correctp;

它完美运作,将所需价值重新计算为美元阀值。

问题在于,我想把价值储存在不同的阵列中,根据已实现的变量:

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

<代码>tmax,$tmin, 等值虽已达美元,但无价值。 此外,如果我分配圈子内的阵列(即<代码>价[j][$i] = valor),则该方仍具有价值,但不在外。

任何人都知道我做了什么错误?

问题回答

类似情况

$tmax = array(); //declare this outside the loop i.e before the loop starts

在开关个案说明中,将以下项目改为:

$tmax[$i] = $valor;

iii

array_push($tmax,$valor);




相关问题
Brute-force/DoS prevention in PHP [closed]

I am trying to write a script to prevent brute-force login attempts in a website I m building. The logic goes something like this: User sends login information. Check if username and password is ...

please can anyone check this while loop and if condition

<?php $con=mysql_connect("localhost","mts","mts"); if(!con) { die( unable to connect . mysql_error()); } mysql_select_db("mts",$con); /* date_default_timezone_set ("Asia/Calcutta"); $date = ...

定值美元

如何确认来自正确来源的数字。

Generating a drop down list of timezones with PHP

Most sites need some way to show the dates on the site in the users preferred timezone. Below are two lists that I found and then one method using the built in PHP DateTime class in PHP 5. I need ...

Text as watermarking in PHP

I want to create text as a watermark for an image. the water mark should have the following properties front: Impact color: white opacity: 31% Font style: regular, bold Bevel and Emboss size: 30 ...

How does php cast boolean variables?

How does php cast boolean variables? I was trying to save a boolean value to an array: $result["Users"]["is_login"] = true; but when I use debug the is_login value is blank. and when I do ...

热门标签