note 25437 added to function.dechex
| From: | monkyNOSPAM at phpfi dot org dot invalid | Date: | Tue, 24 Sep 2002 00:20:38 +0000 |
| Subject: | note 25437 added to function.dechex | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-37165@lists.php.net to get a copy of this message | ||
Here's how to use bitwise operations for RGB2hex conversion. This function returns hexadesimal
rgb value just like one submitted by gurke@bigfoot.com above.
function hexColor($color) {
return dechex(($color[0]<<16)|($color[1]<<8)|$color[2]);
}
example:
$col[0] = 25;
$col[1] = 255;
$col[2] = 55;
print hexColor($col);
--
http://www.php.net/manual/en/function.dechex.php
http://master.php.net/manage/user-notes.php?action=edit+25437
http://master.php.net/manage/user-notes.php?action=delete+25437
http://master.php.net/manage/user-notes.php?action=reject+25437