我不认为这是对的......
$compname = $subformat_$subgame_$subname_$subseason;
正确的语法是什么? 感谢
答案 0 :(得分:3)
$compname = {$subformat.'_'.$subgame.'_'.$subname.'_'.$subseason};
但是你要做的事看起来很奇怪...... 你为什么不使用四维数组?
答案 1 :(得分:2)
$compname = implode('_', array ($subformat,$subgame,$subname,$subseason));
或
$compname = sprintf("%s_%s_%s_%s", $subformat, $subgame, $subname, $subseason);
或
$compname = "$subformat_$subgame_$subname_$subseason";
答案 2 :(得分:0)
我想我可以澄清所提出的问题,因为我也有同样的看法。
结果是通过组合多个新变量来创建先前设置的变量。不要用多个变量创建一个新的变量。
# variable pulled from database
$discover1qty = $r["discovery_1"];
.
.
.
.
$discover20qty = $r["discovery_20"];
$dc = "discover";
$endqty = "qty";
for ($XS = 1; $XS <= 28; $XS++){
# goal: add 3 variables together to get a database variable #
$new_to_old = $dc + $XS + $endqty;
}
# When $new_to_old is called it translate to $discover20qty