Posted By

BILZEEE on 11/20/12


Tagged

php hex convert RGB


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

Some0ne


Convert RGB to Hex


 / Published in: PHP
 

URL: http://schnipsellager.de/code/rgb-zu-hex-umwandeln/

Small php function to convert RGB colors into Hex colors

  1. function rgb2hex($rgb) {
  2. if ($rgb == "" || (!$rgb)) return "#FFFFFF";
  3. $hex = split(",",$rgb);
  4.  
  5. $r = dechex($hex[0]);
  6. $g = dechex($hex[1]);
  7. $b = dechex($hex[2]);
  8.  
  9. return "#".$r.$g.$b;
  10. }

Report this snippet  

You need to login to post a comment.