Witam,
jak najprościej za pomocą funkcji rand wylosować dowolny kolor (byle jaki). Jest jakaś klasa do tego albo algorytm?
np. #339933 itp.
<?php $cfg['primary_color'] = array('black', 'silver', 'gray', 'white', 'maroon', 'red', 'purple', 'fuchsia', 'green', 'lime', 'olive', 'yellow', 'navy', 'blue', 'teal', 'aqua'); function core_random_color($type) { /* * @Name_function: core_random_color * @Description: function returns a random color, depending on $type * @Argument: $type (string) * primary -> 16 combination * short -> 4 096 combination * long -> 16 777 216 combination * @Return: (string) */ // Jeżeli wersja PHP < 4.2.0 wtedy zachodzi potrzeba użycia generator liczb losowych // srand(floor(time() / (60*60*24))); if($type == 'primary') { } else if($type == 'short' || $type == 'long') { $tmp['output'] = '#'; for($h = 0, $tmp['how'] = ($type == 'short' ? 3 : 6); $h < $tmp['how']; ++$h) { } // Zbędna kosmetyka dla fanatyków } return $tmp['output']; } ?>
$kolor = losowy_kolor(); // #2A7F26