<?php
$task204[1]=6.75; $task204[2]=28; $task204[3]=51; $task204[4]=52;
$task205[1]=7; $task205[2]=23; $task205[3]=58; $task205[4]=59;
$task206[1]=9; $task206[2]=27; $task206[3]=53; $task206[4]=56;for ($i=204; $i<=206; $i++) {
$str = "task".$i;
$str = $$str;
for ($j=1; $j<=4; $j++) {
echo $str[$j]."<br>";
}
}
?>

解决方案 »

  1.   

    <?php
    $task204[1]=6.75; $task204[2]=28; $task204[3]=51; $task204[4]=52;
    $task205[1]=7; $task205[2]=23; $task205[3]=58; $task205[4]=59;
    $task206[1]=9; $task206[2]=27; $task206[3]=53; $task206[4]=56;for($i=204;$i<207;$i++)

      for($j=1;$j<5;$++)
      {
       echo '\$task'.$i.$j;
       }
    }
    ?>
      

  2.   

    <?php
    $task[204][1]=6.75; $task[204][2]=28; $task[204][3]=51; $task[204][4]=52;
    $task[205][1]=7; $task[205][2]=23; $task[205][3]=58; $task[205][4]=59;
    $task[206][1]=9; $task[206][2]=27; $task[206][3]=53; $task[206][4]=56;foreach($task as $key) {
    foreach($key as $value){
    echo $value."<br>";
    }
    }
    ?>
      

  3.   

    for ($i=204; $i<=216; $i++) {
    $str = "task".$i;
    $str = $$str;
    for ($j=1; $j<=4; $j++) {
    $str[$j] = round($str[$j]);
    $sql = "select * from test200702 where id like '$i%' order by score3 desc limit $str[$j]";
    $query = mysql_query($sql);
    $row = mysql_fetch_array($query);//通过查询后,得到的变量如何赋值给 $chinese数组呢?不知道用怎么样的数组比较合适?可以用$chinese[$i][$j]这样的形式吗?我在后面需要这些变量,并对变量进行计算。以下代码,屏幕上没有任何显示。
    $chinese[$i][$j] = $row['avg(chinese)'];
    echo $chinese[$i][$j];
    }
    }