Beispiel #1
0
 public static function css2hex($css)
 {
     if (strpos($css, "hsl(") !== false) {
         $hsl = str_replace(["%", "hsl(", ")"], '', $css);
         return Convert::hsl2hex($hsl);
     } else {
         if (strpos($css, "rgb(") !== false) {
             $rgb = str_replace(["rgb(", ")"], '', $css);
             return Convert::rgb2hex($rgb);
         } else {
             if (strpos($css, "#") !== false) {
                 $hex = str_replace("#", '', $css);
                 return $hex;
             } else {
                 if (strpos($css, "hsla(") !== false) {
                     $hsla = str_replace(["%", "hsla(", ")"], '', $css);
                     return Convert::hsla2hex($hsla);
                 } else {
                     if (strpos($css, "rgba(") !== false) {
                         $rgba = str_replace(["rgba(", ")"], '', $css);
                         return Convert::rgba2hex($rgba);
                     }
                 }
             }
         }
     }
 }