Answer the question
In order to leave comments, you need to log in
Random avatar color?
Hello everyone, I'm very interested in the method that Habrahabr uses. Namely, how do they implement the random color of standard avatars for users?
prntscr.com/dwc93m
prntscr.com/dwc99a
looked at the source code
<span class="user-pic_default user-pic_default_47 user-pic_blue"></span>
<span class="user-pic_default user-pic_default_47 user-pic_lilac"></span>
Answer the question
In order to leave comments, you need to log in
$colors = ['blue', 'pink', 'lilac', 'green'];
$color=$colors[ $userId%count($colors) ]
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question