Php color conversion function hex-rgb (convert the hexadecimal format to the decimal format ). Copy the code as follows :? Phpfunctionhex2rgb ($ color) {if ($ color [0] #) {$ coloursubstr ($ color, 1);} if (strlen ($ color) 6) {list ($ r, $ g, $ B) array
The code is as follows:
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 );
}
$ B = hex2rgb ("# ff0 ");
Print_r ($ B );
?>
The http://www.bkjia.com/PHPjc/313586.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/313586.htmlTechArticle code is as follows :? Php function hex2rgb ($ color) {if ($ color [0] = '#') {$ color = substr ($ color, 1 );} if (strlen ($ color) = 6) {list ($ r, $ g, $ B) = array...