generate a random color rgb code with php

this code will generate a random color every time its loaded using the rand function in php and generate something like this. .random-color { color:rgb(111,222,111); }

PHP Code


<?php

// return a random color rgb string.
$rgb = "";
for($i=0; $i<=3; $i++) {
  $number = rand(0,255);
  $rgb .= "$number,";
}
$rgb = rtrim($rgb,",");
echo $rgb_css = ".random_color{color:rgb($rgb);}"

?>

.random_color{color:rgb(157,45,9);}

I Am a Random Color!

Other Items in php
Related Search Terms
Page Views

This page has been viewed 372 times.

Search Code
Search Code by entering your search text above.
Welcome

This is my test area for webdev. I keep a collection of code snippits here, mostly for my reference. Also if i find a good site, i usually add it here.

âĪðŸ‘Đ‍ðŸ’ŧðŸ•đ

Random Quote
For a long time it had seemed to me that life was about to begin - real life. But there was always some obstacle in the way, something to be gotten through first, some unfinished business, time still to be served, or a debt to be paid. Then life would begin. At last it dawned on me that these obstacles were my life.
Alfred D. Souza