using minus numbers with rand() function? or alternative method
<p>I have encountered a logical hurdle!</p>

<p>I have a page with 6 actions on. when you click an action, it simply returns a true or false.  </p>

<p>Each action has its own chance of success, and the true /false is based on whether a random generated number is higher or lower than the actions success value.</p>

<p>the chance values are stored in the database like:  <strong>10-20-30-40-50-60</strong></p>

<p>I call these values using explode and insert them using implode.</p>

<p>What I want to achieve is to change these chances values to either 1 more, 1 less or the same (upto a max of 65), each time an action is clicked and the form submitted, </p>

<p>This is what I have attempted but to no avail.</p>

<pre><code>&lt;?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] &gt;= 2 ){
             $chance[0] = $chance[0] + rand(-1,1) ; 

    }elseif ($chance[0] &gt;= 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] &gt;= 2 ){
             $chance[1] = $chance[0] + rand(-1,1) ; 

    }elseif ($chance[1] &gt;= 65 ){
             $chance[1] = 65;
    }
</code></pre>

<p>etc.. for all chance[0] to chance[5]</p>

<p>then,</p>

<pre><code>$chancearray = array($chance[0], $chance[1], $chance[2], $chance[3], $chance[4], $chance[5]);

$newchancearray = implode("-",$chancearray);

?&gt;
</code></pre>

<p>and insert it into the database.</p>

<p>can anyone help me with the logic for adding -1, 0 or 1 to the chance values after submitting the form?</p>

<p>at the moment its changing all values to 2 ??</p>

<p>so if chance was 10-20-30-40-50-60, once submitted, it becomes 2-2-2-2-2-2.</p>

<p>help? :(</p>
