Posted By

Unreal on 08/05/09


Tagged

hex to RGB


Versions (?)

Who likes this?

2 people have marked this snippet as a favorite

vali29
umang_nine


Hex to RGB


 / Published in: PHP
 

URL: http://www.devwords.com

Another hex to RGB function. Probably pointless me sharing it but ah well.

  1. function hex2rgb($hex){
  2. $rgb = array();
  3. $rgb['r'] = hexdec(substr($hex, 0, 2));
  4. $rgb['g'] = hexdec(substr($hex, 2, 2));
  5. $rgb['b'] = hexdec(substr($hex, 4, 2));
  6. return $rgb;
  7. }
  8.  
  9. Usage:
  10. print_r(hex2rgb('#009999'));
  11. Returns:
  12. (
  13. [r] => 0
  14. [g] => 9
  15. [b] => 153
  16. )

Report this snippet  

You need to login to post a comment.