note 29404 added to function.dechex
| From: | fp at flocons dot php dot net | Date: | Wed, 12 Feb 2003 17:12:25 +0000 |
| Subject: | note 29404 added to function.dechex | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-43830@lists.php.net to get a copy of this message | ||
sherifgayed code above doesn't work when r,g or b are very small (for example rgb(11,6,2)),
because HTML browser are expecting a six characters string after the # char.
Use the following to add zeros in front smallest values :
$htmlColor = str_pad(dechex($red),2,"0",STR_PAD_LEFT)
$htmlColor .= str_pad(dechex($green),2,"0",STR_PAD_LEFT)
$htmlColor .= str_pad(dechex($blue),2,"0",STR_PAD_LEFT)
--
http://www.php.net/manual/en/function.dechex.php
http://master.php.net/manage/user-notes.php?action=edit+29404
http://master.php.net/manage/user-notes.php?action=delete+29404
http://master.php.net/manage/user-notes.php?action=reject+29404