note 100725 deleted from function.hexdec by danbrown
| From: | danbrown@php.net | Date: | Tue, 02 Nov 2010 21:54:14 +0000 |
| Subject: | note 100725 deleted from function.hexdec by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-173700@lists.php.net to get a copy of this message | ||
Note Submitter: OntoDevelopment . com
----
I used "k10206 at naver dot com" and expanded it to accept shorthand and #.
<?php
function hex2rgb($hex){
$hex = trim($hex,'#');
if(strlen($hex)==3) $hex=$hex[0].$hex[0].$hex[1].$hex[1].$hex[2].$hex[2];
if(strlen($hex)!=6) return false;
$dec = hexdec($hex);
return
array("R"=>0xFF&($dec>>0x10),"G"=>0xFF&($dec>>0x8),"B"=>0xFF&$dec);
}
?>