This article mainly introduces php's simple method of generating random colors, involving php's random number and array related operation skills. if you need it, refer to the example below to illustrate the simple method of generating random colors in php. We will share this with you for your reference. The details are as follows:
<? Php // Method 1: $ 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)]; echo $ color."
"; // Method 2: printf (" # % 06X \ n ", mt_rand (0, 0 xFFFFFF);?>
The running result is as follows:
# 4338cd #7EF5B8
For information on color value conversion and acquisition, refer to the online tool on this site:
RGB color encoding generator
Online Webpage color matching tool
RGB color query table _ color code table _ English name of colors