对你们来说可能是一个简单的问题。无法在Google上找到它。PHP连接变量
我想连接两个变量的名称;
$i=0;
for ($i=0;$i<5;$i++){
if($array[$i]>0){
$test.$i=//do something
}else{
$test.$i=//do something
}
}
//echo $test0 gives me nothing.
//echo $test1 gives me nothing.
我知道我不能使用$ test。$但我不知道该怎么做。任何帮助?谢谢!
不错的链接! +1给你。 – FlyingCat 2010-05-20 19:05:31
接受的答案,因为链接! :D – FlyingCat 2010-05-20 19:06:51
OP的代码的最后两行暗示如果$ i == 0,他试图访问$ test0。在这种情况下,如果$ test未定义,那么$ test将评估为空字符串,{$ test。$ i}将评估为“0”。 – Dazarath 2010-05-20 19:08:44