Provides various official and user-released code examples. For code reference, you are welcome to exchange and learn a very useful php color conversion function, which is used to convert the color value expressed by hex to the rgb format. Example: # dfdfdf to (239,239,239)
Function hex2rgb ($ color ){
If ($ color [0] = '#'){
$ Color = substr ($ color, 1 );
}
If (strlen ($ color) = 6 ){
List ($ r, $ g, $ B) = array ($ color [0]. $ color [1], $ color [2]. $ color [3], $ color [4]. $ color [5]);
} Elseif (strlen ($ color) = 3 ){
List ($ r, $ g, $ B) = array ($ color [0]. $ color [0], $ color [1]. $ color [1], $ color [2]. $ color [2]);
} Else {
Return false;
}
$ R = hexdec ($ r );
$ G = hexdec ($ g );
$ B = hexdec ($ B );
Return array ('red' => $ r, 'green' => $ g, 'blue' => $ B );
}
?>
Http://blog.ddian.cn /? Posting = 896
AD: truly free, domain name + VM + enterprise mailbox = 0 RMB