src/Marando/Color/Color.php
private static function hex2rgb($hex, &$r, &$g, &$b)
    {
        // Remove hash if present
        $hex = preg_replace('/[^a-fA-F0-9]/', '', $hex);

        if (strlen($hex) == 6) {
            // 6-digit hex
            $r = substr($hex, 0, 2);
            $g = substr($hex, 2, 2);
            $b = substr($hex, 4, 2);
        } else {
            // 3-digit hex, pad to 6 total...
            $r = $hex[0] . $hex[0];
            $g = $hex[1] . $hex[1];
            $b = $hex[2] . $hex[2];
        }

        $r = hexdec($r);
        $g = hexdec($g);
        $b = hexdec($b);
    }
private static function hex2rgb($hex, &$r, &$g, &$b)
    {
        // Remove hash if present
        $hex = preg_replace('/[^a-fA-F0-9]/', '', $hex);

        if (strlen($hex) == 6) {
            // 6-digit hex
            $r = substr($hex, 0, 2);
            $g = substr($hex, 2, 2);
            $b = substr($hex, 4, 2);
        } else {
            // 3-digit hex, pad to 6 total...
            $r = $hex[0] . $hex[0];
            $g = $hex[1] . $hex[1];
            $b = $hex[2] . $hex[2];
        }

        $r = hexdec($r);
        $g = hexdec($g);
        $b = hexdec($b);
    }
private static function hex2rgb ( $ hex , & $ r , & $ g , & $ b ) { // Remove hash if present $ hex = preg_replace ( '/[^a-fA-F0-9]/' , '' , $ hex ) ; if ( strlen ( $ hex ) == 6 ) { // 6-digit hex $ r = substr ( $ hex , 0 , 2 ) ; $ g = substr ( $ hex , 2 , 2 ) ; $ b = substr ( $ hex , 4 , 2 ) ; } else { // 3-digit hex, pad to 6 total... $ r = $ hex [ 0 ] . $ hex [ 0 ] ; $ g = $ hex [ 1 ] . $ hex [ 1 ] ; $ b = $ hex [ 2 ] . $ hex [ 2 ] ; } $ r = hexdec ( $ r ) ; $ g = hexdec ( $ g ) ; $ b = hexdec ( $ b ) ; }
Converts an RGB Hex code to RGB.

@param $hex RGB Hex code, in format #7d52eb or #7d5
@param $r   Red, 0-255
@param $g   Green, 0-255
@param $b   Blue,0-255
Converts an RGB Hex code to RGB .