title: Generate high contrast random color using PHP
body: <p>I need to generate random colors for all the users in the system. The trick is that 2 users cant have very similar colors, they need to be distinguishable. I have the code to generate random colors given the original mix color but cant find a way to generate random colors with high contrast using only PHP </p>
  
  <pre><code>public static function generateRandomColor($rgb)
  {
      $red = rand(1, 256);
      $green = rand(1, 256);
      $blue = rand(1, 256);
  
      if (! empty($rgb))
      {
          $red = ($red + $rgb['red']) / 2;
          $green = ($green + $rgb['green']) / 2;
          $blue = ($blue + $rgb['blue']) / 2;
      }
  
      $color = "rgb({$red}, {$green}, {$blue})";
  
      return $color;
  }
  </code></pre>
  
  <p>and then i have a loop:</p>
  
  <pre><code>$colorsArr = array();
  $mixed = array('red' =&gt; 255, 'green' =&gt; 255, 'blue' =&gt; 255);
  for($i = 0; $i &lt; count($users); $i++)
  {
      $color = generateRandomColor($mixed);
  
      $colorsArr .= '&lt;div style="width:25px; height: 25px; background-color: ' . $color . '"&gt;&lt;/div&gt;';
  }
  </code></pre>
  
  <p>now this generates colors but some colors look like each other. The goal is to have an unique color for each user.
  any help appreciated thanks.</p>
  
  <p><strong>NOTE:</strong> i do not want to hardcode the colors for 500 users</p>