Prevent Foreach Array Give Same Value : <p>I have this array code</p>

<pre><code>$data = array();
foreach($getAllUserTicketHistoryJson as $value){
    $data[$value['user_id']] = number_format((float)($value['total_ticket'] / $getAllTicketRound * 100), 2, '.', '');
}
$array=$data;
</code></pre>

<p>which will give output</p>

<pre><code>array(4) { [4]=&gt; string(5) "16.28" [3]=&gt; string(4) "5.81" [2]=&gt; string(5) "11.63" [5]=&gt; string(5) "66.28" } 
</code></pre>

<p>the array is user_id and chance to win from 100%.</p>

<p>and I want to show 3 random winner without repeat the first winner. Means that if user already win they cannot win again.</p>

<p>I created this code</p>

<pre><code>    $number=rand(0,array_sum($array));
    $starter=0;
    foreach($array as $key =&gt; $val)
    {
        $starter+=$val;
        if($number&lt;=$starter)
        {
                $ret=$key;
                break;
        }
    }
for($i=0;$i&lt;3;$i++)
{
    echo 'Winner is '.$ret.'&lt;br/&gt;';
}
</code></pre>

<p>The code will give output</p>

<pre><code>Winner is 5
Winner is 5
Winner is 5
</code></pre>

<p>The problem is, how to show 3 winner based on their chance without repeating the first winner. The result should be like this</p>

<pre><code>Winner is 4
Winner is 5
Winner is 2
</code></pre>

<p>thanks for helping me</p>
