note 38733 deleted from function.imagecolorclosest by didou
| From: | didou@php.net | Date: | Mon, 05 Jan 2004 10:15:56 +0000 |
| Subject: | note 38733 deleted from function.imagecolorclosest by didou | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-62939@lists.php.net to get a copy of this message | ||
Note Submitter: xeno
----
With this function you can change a hexadecimal color to a decimal one:
<?php
function hextodec($hex){
$hex=split('#', $hex);
$hex=end($hex);
$dec=array(
"r"=>hexdec(substr($hex, 0, 2)),
"g"=>hexdec(substr($hex, 2, 2)),
"b"=>hexdec(substr($hex, 4, 2))
);
return $dec;
}
//Use this function:
$color=hextodec("#5522ff");
echo $color["r"].', '.$color["g"].',
'.$color["b"];
?>
It returns an array like this
Array(
[r] => 85
[g] => 34
[b] => 255
)