Amit Dhamu

Software Engineer

Generate Random Colour

$rand = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'];

$random_colour = '#' . $rand[rand(0,15)].$rand[rand(0,15)].$rand[rand(0,15)].$rand[rand(0,15)].$rand[rand(0,15)].$rand[rand(0,15)];

Also, an alternate one-liner:

$random_colour = '#' . strtoupper(dechex(rand(0,10000000)));

 random colour / php

Browser Selection ColourPHP Range

Show Comments

Made with by Amit Dhamu.
© MMXX. All rights reserved.