我有"windfr"
个变量,该变量具有值。例如310。我想创建一个新变量"windfr" + or - 1
0
$windfr = 310
$rand = rand(0,1);
if($rand == 1){ ... }
答案 0 :(得分:3)
答案 1 :(得分:1)
$windfr = 310;
$rand = rand(0,1);
if($rand == 1){
$windfr += 10;
}
else {
$windfr -= 10;
}
答案 2 :(得分:0)
简单的if / else语句:
$windfr = 310
$rand = rand(0,1);
if($rand == 1) $newvar = $windfr + 10; else $newvar = $windfr - 10;