Random HTML color code for charts

When you do stack charts, it is important that the colors differ so much from each other that they are not mixed up. I made a function that returns a predetermined number of color codes that I've tested that is not too similar to each other.

When these color codes ends, a random number generator creates new color codes, these are not controlled, but my tests shows that it will do well.

Maybe I am doing a new feature one day that randomly generates an indefinite series of colors that can lie next to each other without being mixed up.

<?php
function _get_color($i = FALSE) {
   
$out = array(
               
'#0000dd',
               
'#dd0000',
               
'#21B6A8',
               
'#87907D',
               
'#ec6d66',
               
'#177F75',
               
'#B6212D',
               
'#B67721',
               
'#da2d8b',
               
'#7F5417',
               
'#FF8000',
               
'#61e94c',
               
'#FFAABF',
               
'#91C3DC',
               
'#FFCC00',
               
'#E5E0C1',
               
'#68BD66',
               
'#179CE8',
               
'#BBFF20',
               
'#30769E',
               
'#FFE500',
               
'#C8E9FC',
               
'#758a09',
               
'#00CCFF',
               
'#FFC080',
               
'#4086AA',
               
'#FFAABF',
               
'#0000AA',
               
'#AA6363',
               
'#AA9900',
               
'#1A8BC0',
               
'#ECF8FF',
               
'#758a09',
               
'#dd3100',
               
'#dea04a',
               
'#af2a30',
               
'#EECC99',
               
'#179999',
               
'#BBFF20',
               
'#a92e03',
               
'#dd9cc9',
               
'#f30320',
               
'#579108',
               
'#ce9135',
               
'#acd622',
               
'#e46e46',
               
'#53747d',
               
'#36a62a',
               
'#83877e',
               
'#e82385',
               
'#73f2f2',
               
'#cb9fa4',
               
'#12c639',
               
'#f51b2b',
               
'#985d27',
               
'#3595d5',
               
'#cb9987',
               
'#d52192',
               
'#695faf',
               
'#de2426',
               
'#295d5a',
               
'#824b2d',
               
'#08ccf6',
               
'#e82a3c',
               
'#fcd11a',
               
'#2b4c04',
               
'#3011fd',
               
'#1df37b',
               
'#af2a30',
               
'#c456d1',
               
'#dcf174',
               
'#025df6',
               
'#0ab24f',
               
'#c0d962',
               
'#62369f',
               
'#73faa9',
               
'#fb453c',
               
'#0487a4',
               
'#ce9e07',
               
'#2b407e',
               
'#c28551',
                  
    );
   
    if (
$i !== FALSE AND $i < count($out)) {
       
$out = $out[$i];
    }else{
       
$out = rgb2html(rand(0,255), rand(0,255), rand(0,255));
    }
   
   
    return
$out;
}
//Test
for($i=0; $i <= 100; $i++) {
 
$c = _get_color($i);
  echo
"<div style='width:150px; height:20px; background:".$c.";'>'$c',</div>";
 
//echo "<div style='width:100px; height:100px; background-color: $color; float: left;'>'$color',</div></p>";
   
}

?>

Test output with fixed colors:

'#0000dd',
'#dd0000',
'#21B6A8',
'#87907D',
'#ec6d66',
'#177F75',
'#B6212D',
'#B67721',
'#da2d8b',
'#7F5417',
'#FF8000',
'#61e94c',
'#FFAABF',
'#91C3DC',
'#FFCC00',
'#E5E0C1',
'#68BD66',
'#179CE8',
'#BBFF20',
'#30769E',
'#FFE500',
'#C8E9FC',
'#758a09',
'#00CCFF',
'#FFC080',
'#4086AA',
'#FFAABF',
'#0000AA',
'#AA6363',
'#AA9900',
'#1A8BC0',
'#ECF8FF',
'#758a09',
'#dd3100',
'#dea04a',
'#af2a30',
'#EECC99',
'#179999',
'#BBFF20',
'#a92e03',
'#dd9cc9',
'#f30320',
'#579108',
'#ce9135',
'#acd622',
'#e46e46',
'#53747d',
'#36a62a',
'#83877e',
'#e82385',
'#73f2f2',
'#cb9fa4',
'#12c639',
'#f51b2b',
'#985d27',
'#3595d5',
'#cb9987',
'#d52192',
'#695faf',
'#de2426',
'#295d5a',
'#824b2d',
'#08ccf6',
'#e82a3c',
'#fcd11a',
'#2b4c04',
'#3011fd',
'#1df37b',
'#af2a30',
'#c456d1',
'#dcf174',
'#025df6',
'#0ab24f',
'#c0d962',
'#62369f',
'#73faa9',
'#fb453c',
'#0487a4',
'#ce9e07',
'#2b407e',
'#c28551',
Knowledge keywords: