title: prevent same selection with random array
body: <p>I have the following code for selecting a random item out of an array each time a foreach loops through it's cycle. </p>
  
  <pre><code>&lt;?php $variables = array('success', 'warning', 'info', 'danger'); ?&gt;
     &lt;?php foreach($os-&gt;list as $list): $var = 'success'; ?&gt;
        &lt;div class="progress-bar progress-bar-&lt;?php echo $variables[array_rand($variables)]; ?&gt;" style="width: &lt;?php echo $list-&gt;metrics-&gt;visits; ?&gt;%" title="&lt;?php echo $list-&gt;os.' '.$list-&gt;version; ?&gt;"&gt;
           &lt;span class="sr-only"&gt;&lt;?php echo $list-&gt;metrics-&gt;visits; ?&gt;%&lt;/span&gt;
         &lt;/div&gt;
      &lt;?php endforeach; ?&gt;
  </code></pre>
  
  <p>My only problem is that one time it chooses <code>success</code> and then the next time it chooses <code>success</code> you then can't tell the difference in the data. I would be okay if it selected something like: </p>
  
  <p><code>success, info, danger, success, danger, info</code> </p>
  
  <p>Just not: </p>
  
  <p><code>success, info, info, danger, success, success</code></p>
  
  <p>Where two items end up side by side. </p>
  
  <p>Is there a way to do this or am I wasting my time?</p>
  
  <p><strong>UPDATE</strong></p>
  
  <p>I though this up but i'm not sure where to go with it:</p>
  
  <pre><code>&lt;?php foreach($os-&gt;list as $list): $var = 'success'; ?&gt;
     &lt;?php
      if($var){
  
        $var1 = $var;
  
        $var = $variables[array_rand($variables)];
  
        if($var == $var1){
  
  
        }
       }
     ?&gt;
     &lt;div class="progress-bar progress-bar-&lt;?php echo $var; ?&gt;" style="width: &lt;?php echo $list-&gt;metrics-&gt;visits; ?&gt;%" title="&lt;?php echo $list-&gt;os.' '.$list-&gt;version; ?&gt;"&gt;
  </code></pre>