Back to PhocaGalleryUtils class

Method htmlToRgb

public static
htmlToRgb
(mixed $clr)

Method htmlToRgb - Source code

public static function htmlToRgb($clr)
{
    if ($clr[0] == '#') {
        $clr = substr($clr, 1);
    }
    if (strlen($clr) == 6) {
        list($r, $g, $b) = array($clr[0] . $clr[1], $clr[2] . $clr[3], $clr[4] . $clr[5]);
    } else {
        if (strlen($clr) == 3) {
            list($r, $g, $b) = array($clr[0] . $clr[0], $clr[1] . $clr[1], $clr[2] . $clr[2]);
        } else {
            $r = $g = $b = 255;
        }
    }
    $color[0] = hexdec($r);
    $color[1] = hexdec($g);
    $color[2] = hexdec($b);
    return $color;
}