Created
          February 11, 2015 13:27 
        
      - 
      
- 
        Save yanknudtskov/42b620458e63f0efaa3c to your computer and use it in GitHub Desktop. 
    Convert rgb colors to hex
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | <?php | |
| function rgb2hex($rgb) { | |
| $hex = "#"; | |
| $hex .= str_pad(dechex($rgb[0]), 2, "0", STR_PAD_LEFT); | |
| $hex .= str_pad(dechex($rgb[1]), 2, "0", STR_PAD_LEFT); | |
| $hex .= str_pad(dechex($rgb[2]), 2, "0", STR_PAD_LEFT); | |
| return $hex; // returns the hex value including the number sign (#) | |
| } | |
| ?> | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment