In this paper, we describe the simple method of generating random colors in PHP. Share to everyone for your reference, as follows:
<?php //The first method: $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. "
"; The second method: printf ("#%06x\n", Mt_rand (0, 0xFFFFFF));? >
The results of the operation are as follows:
For color value conversion and acquisition can also refer to the site online tools:
RGB Color Coding Generator
Online Web color Matching tool
RGB Color Query Chart _ color code table _ color of the English name Daquan
More readers interested in PHP related content can view the topic: "PHP array" operation Skills Daquan, "PHP Math Skills Summary", "PHP graphics and pictures Operation Skills Summary", "PHP operation Office Document tips summary (including Word,excel, access,ppt), "PHP Date and Time usage summary", "PHP primer for Object-oriented programming", "PHP String Usage Summary", "Getting Started with Php+mysql database operations" and "PHP Common Database Operations Skills Summary"
I hope this article is helpful to you in PHP programming.
The above describes the simple generation of PHP random color method, including the aspects of the content, I hope the PHP tutorial interested in a friend helpful.