$rgbArray['red'] = hexdec(str_repeat(substr($hexStr, 0, 1), 2)); $rgbArray['green'] = hexdec(str_repeat(substr($hexStr, 1, 1), 2)); $rgbArray['blue'] = hexdec(str_repeat(substr($hexStr, 2, 1), 2)); } else { return false; } return $returnAsString ? implode($separator, $rgbArray) : $rgbArray; // returns the rgb string or the associative array } /** * Extract a HEX colour and opacity from rgba colour */ function rgba2hexop($rgbaStr) { if (preg_match('/rgba\\(([0-9]+),([0-9]+),([0-9]+),([0-9\\.]+)\\)/', $rgbaStr, $matches)) { $hexStr = ''; for ($i = 1; $i < 4; $i++) { $hex = dechex($matches[$i]); if (strlen($hex) == 1) { $hex = "0" . $hex; } $hexStr .= $hex; } return array('hex' => '#' . $hexStr, 'op' => floatval($matches[4])); } else { return array('hex' => '#000000', 'op' => 0.5); } } } wkwThemeAdmin::register(); }