note 73397 deleted from function.dechex by danbrown
| From: | danbrown@php.net | Date: | Tue, 16 Feb 2010 23:27:56 +0000 |
| Subject: | note 73397 deleted from function.dechex by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-166038@lists.php.net to get a copy of this message | ||
Note Submitter: jon at ovbb dot org
----
@poj and AsakuraStar,
You're probably better off doing this instead to get what you want:
<?php
function rgbhex($red, $green, $blue)
{
return sprintf('#%02X%02X%02X', $red, $green, $blue);
}
echo rgbhex(15, 15, 15); // prints #0F0F0F
?>
It's cleaner and most likely faster. May not even want to encapsulate it in a function, as
it's just a one-liner.