PHP - Convert HEX value to RBG
function hextorgb($hexvalue) {
if($hexvalue[0] == '#') {
$hexvalue = substr( $hexvalue, 1);
if(strlen( $hexvalue ) == 6) {
list($r, $g, $b) = array($hexvalue[0] . $hexvalue[1], $hexvalue[2] . $hexvalue[3], $hexvalue[4] . $hexvalue[5]);
elseif (strlen($hexvalue) == 3) {
list($r,$g,$b) = array($hexvalue[0] . $hexvalue[0], $hexvalue[1] . $hexvalue[1], $hexvalue[2] . $hexvalue[2]);
else {
return false;
$r = hexdec($r);
$g = hexdec($g);
$b = hexdec($b);
return array('R' => $r, 'G' => $g, 'B' => $b);

/* SYNTAX */
$rgb = hextorgb('#fff000');

Posted in:

GnasheR's Snippets

PHP as it's known today is actually the successor to a product named PHP/FI. Created in 1994 by Rasmus Lerdorf, the very first incarnation of PHP was a simple set of Common Gateway Interface (CGI) binaries written in the C programming language. Originally used for tracking visits to his online resume, he named the suite of scripts "Personal Home Page Tools," more frequently referenced as "PHP Tools." Over time, more functionality was desired, and Rasmus rewrote PHP Tools, producing a much larger and richer implementation. This new model was capable of database interaction and more, providing a framework upon which users could develop simple dynamic web applications such as guestbooks. In June of 1995, Rasmus released the source code for PHP Tools to the public, which allowed developers to use it as they saw fit. This also permitted and encouraged users to provide fixes for bugs in the code, and to generally improve upon it.
Go To Top