Posted By

scopefragger on 09/01/09


hex convert RGB

Versions (?)

Who likes this?

2 people have marked this snippet as a favorite


Convert RGB to HEX

 / Published in: PHP


Ever needed to convert rgb to hex on your website, maybe you have a slider that handles rgb but your backend uses hex, this issue can be resolved easily be using the following code. Remember to keep in mind that php and html primarily uses hex colors.

  1. function rgb2hex($rgb){
  2. return sprintf("%06X", $rgb);
  3. }

Report this snippet  

You need to login to post a comment.