<?php
function hexrgb($hexstr) {
//this "if" is optional if you wont use three character format
if(strlen($hexstr) < 6){
$hexstr = str_repeat($hexstr[0],2) . str_repeat($hexstr[1],2) . str_repeat($hexstr[2],2);
}
$int = hexdec($hexstr);
return array("red" => 0xFF & ($int >> 0x10), "green" => 0xFF & ($int >> 0x8), "blue" => 0xFF & $int);
}
print_r(hexrgb("00f"));