note 29404 rejected from function.dechex by nicos
| From: | nicos@php.net | Date: | Thu, 13 Feb 2003 02:31:18 +0000 |
| Subject: | note 29404 rejected from function.dechex by nicos | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-43860@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)