Custom PHP Function accepts hexadecimal color code as input and converts it RGB.
Function
function hexToRgb($code){
list($r, $g, $b) = sscanf($code, "#%02x%02x%02x");
return $r . ',' . $g . ',' . $b;
}
Calling The Function
echo hexToRgb('#00ff00');
Output
0,255,0

Leave A comment
Email address is optional and will not be published. Only add email address if you want a reply from blog author.
Please fill required fields marked with *