Quantcast
Channel: PHP Freaks: PHP Help
Viewing all articles
Browse latest Browse all 13200

Coloring usernames in table based off IP Address?

$
0
0

How would I go about coloring usernames (random color) based off an IP address?

 

For example, I want all user's with IP "127.0.0.1" to be red in the table:

 

 

$rand = array('0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f');
$color = '#'.$rand[rand(0,15)].$rand[rand(0,15)].$rand[rand(0,15)].$rand[rand(0,15)].$rand[rand(0,15)].$rand[rand(0,15)];
 
Example:
 
User1(red) - 127.0.0.1
User2(red) - 127.0.0.1
User3(blue) - 44.43.44.44
User4(green) - 54.45.45.45

Viewing all articles
Browse latest Browse all 13200

Trending Articles