使用rand()函数的减号?或者另一种方法


using minus numbers with rand() function? or alternative method

我遇到了一个逻辑障碍!

我有一个页面上有6个动作。当您单击一个操作时,它只返回true或false。

每个动作都有自己的成功机会,而true/false是基于一个随机生成的数字是高于还是低于动作的成功值。

机会值存储在数据库中如下:10-20-30-40-50-60

我用explosion调用这些值,用implode插入它们。

我想要实现的是将这些机会值更改为1多,1少或相同(最多65),每次单击操作并提交表单,

这是我尝试过的,但无济于事。

<?PHP
//CHANCE 0 (action 1)
if ($chance[0] = 0 ){ 
    $chance[0] = rand(0,1); 
    }elseif ($chance[0] = 1 ){
             $chance[0] = rand(1,2); 
    }elseif ($chance[0] >= 2 ){
             $chance[0] = $chance[0] + rand(-1,1) ; 
    }elseif ($chance[0] >= 65 ){
             $chance[0] = 65;
    }
//CHANCE 1 (action 2)
if ($chance[1] = 0 ){ 
    $chance[1] = rand(0,1); 
    }elseif ($chance[1] = 1 ){
             $chance[1] = rand(1,2); 
    }elseif ($chance[1] >= 2 ){
             $chance[1] = $chance[0] + rand(-1,1) ; 
    }elseif ($chance[1] >= 65 ){
             $chance[1] = 65;
    }

等。For all chance[0] to chance[5]

,

$chancearray = array($chance[0], $chance[1], $chance[2], $chance[3], $chance[4], $chance[5]);
$newchancearray = implode("-",$chancearray);
?>

并插入到数据库中。

谁能帮助我与逻辑添加- 1,0或1的机会值提交表单后?

现在所有的值都变成了2 ??

所以如果机会是10-20-30-40-50-60,一旦提交,它就变成了2-2-3 -2-2-2。

帮助吗?(

将IF上使用的布尔表达式的=改为==

代替

if ($chance[1] = 0 ){ 

应为

if ($chance[1] == 0 ){ 

你知道"=="吗?

代码错误