layers_hex2rgb

The Layers layers hex2rgb function.

Description

layers_hex2rgb( $hex ); 

Parameters (1)

0. $hex
The hex.

Usage

  1. if ( !function_exists( 'layers_hex2rgb' ) ) { 
  2. require_once '/core/helpers/color.php'; 
  3.  
  4. // The hex. 
  5. $hex = null; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = layers_hex2rgb($hex); 
  9.  

Defined (1)

The function is defined in the following location(s).

/core/helpers/color.php  
  1. function layers_hex2rgb($hex) { 
  2. $hex = str_replace("#", "", $hex); 
  3.  
  4. if(strlen($hex) == 3) { 
  5. $r = hexdec(substr($hex, 0, 1).substr($hex, 0, 1)); 
  6. $g = hexdec(substr($hex, 1, 1).substr($hex, 1, 1)); 
  7. $b = hexdec(substr($hex, 2, 1).substr($hex, 2, 1)); 
  8. } else { 
  9. $r = hexdec(substr($hex, 0, 2)); 
  10. $g = hexdec(substr($hex, 2, 2)); 
  11. $b = hexdec(substr($hex, 4, 2)); 
  12. $rgb = array($r, $g, $b); 
  13.  
  14. return $rgb; // returns an array with the rgb values