我想创建一个数组值为: 3,2,1 ....我想使用array_push和forloop。 我写了下面的代码不工作..php数组动态创建不正确的值
============
<?PHP
$temp0=3;
$temp1=2;
$temp2=1;
$temp3=1;
$temp4=1;
$temp5=1;
$arraytemp=array();
for($i=0;$i<4;$i++)
{
$r="temp";
$dd=$r.$i;
array_push($arraytemp,$dd);
}
echo $arraytemp[3];
?>
可以请你让我知道我缺少
你的代码正常工作...你在找什么?你的代码输出:** Array([0] => temp0 [1] => temp1 [2] => temp2 [3] => temp3)** – Gowri
@gowri:他需要上面声明的变量的值而不是变量名称本身 –