function afift_hex2rgbcolors($c){
$c = str_replace("#", "", $c);
if(strlen($c) == 3){
$r = hexdec( $c[0] . $c[1] );
$g = hexdec( $c[1] . $c[1] );
$b = hexdec( $c[2] . $c[1] );
}
elseif (strlen($c) == 6 ){
$r = hexdec( $c[0] . $c[2] );
$g = hexdec( $c[2] . $c[2] );
$b = hexdec( $c[4] . $c[2] );
}
else{
$r = 'ff';
$g = 'ff';
$b = '00';
}
return Array("red" => $r, "green" => $g, "blue" => $b);
}
}
Convert hexadecimal color to rgb in PHP
